File U_25-Reclaim-a-tab-stop.patch of Package slurm.32299
From: Tim Wickberg <tim@schedmd.com>
Date: Wed Nov 29 15:51:13 2023 -0700
Subject: [PATCH 25/28]Reclaim a tab stop.
Patch-mainline: Upstream
Git-repo: https://github.com/SchedMD/slurm
Git-commit: 162d865e8393f4f6f4549e6d6e5dc63d264d2654
References: bsc#1218046, bsc#1218050, bsc#1218051, bsc#1218053
Signed-off-by: Egbert Eich <eich@suse.de>
---
src/common/pack.c | 51 +++++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/src/common/pack.c b/src/common/pack.c
index 6883247130..620d82c542 100644
--- a/src/common/pack.c
+++ b/src/common/pack.c
@@ -1002,6 +1002,8 @@ unpack_error:
*/
int unpackstr_xmalloc_escaped(char **valp, uint32_t *size_valp, Buf buffer)
{
+ uint32_t cnt;
+
*valp = NULL;
safe_unpack32(size_valp, buffer);
@@ -1012,37 +1014,38 @@ int unpackstr_xmalloc_escaped(char **valp, uint32_t *size_valp, Buf buffer)
error("%s: Buffer to be unpacked is too large (%u > %u)",
__func__, *size_valp, MAX_PACK_MEM_LEN);
return SLURM_ERROR;
- } else if (*size_valp > 0) {
- uint32_t cnt = *size_valp;
+ }
- if (remaining_buf(buffer) < cnt)
- return SLURM_ERROR;
+ cnt = *size_valp;
- /* make a buffer 2 times the size just to be safe */
- *valp = xmalloc_nz((cnt * 2) + 1);
- if (*valp) {
- char *copy = NULL, *str, tmp;
- uint32_t i;
- copy = *valp;
- str = &buffer->head[buffer->processed];
-
- for (i = 0; i < cnt && *str; i++) {
- tmp = *str++;
- if ((tmp == '\\') || (tmp == '\'')) {
- *copy++ = '\\';
- (*size_valp)++;
- }
-
- *copy++ = tmp;
+ if (remaining_buf(buffer) < cnt)
+ return SLURM_ERROR;
+
+ /* make a buffer 2 times the size just to be safe */
+ *valp = xmalloc_nz((cnt * 2) + 1);
+ if (*valp) {
+ char *copy = NULL, *str, tmp;
+ uint32_t i;
+ copy = *valp;
+ str = &buffer->head[buffer->processed];
+
+ for (i = 0; i < cnt && *str; i++) {
+ tmp = *str++;
+ if ((tmp == '\\') || (tmp == '\'')) {
+ *copy++ = '\\';
+ (*size_valp)++;
}
- /* Since we used xmalloc_nz, terminate the string. */
- *copy++ = '\0';
+ *copy++ = tmp;
}
- /* add the original value since that is what we processed */
- buffer->processed += cnt;
+ /* Since we used xmalloc_nz, terminate the string. */
+ *copy++ = '\0';
}
+
+ /* add the original value since that is what we processed */
+ buffer->processed += cnt;
+
return SLURM_SUCCESS;
unpack_error: