Skip to content

Commit

Permalink
Move va_list setup earlier in function
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Rift <[email protected]>
  • Loading branch information
riftEmber committed Dec 9, 2024
1 parent d0fb700 commit 47ec125
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtime/src/chpl-launcher-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ char* chpl_append_to_cmd(char* cmdBuf, const char* format, ...) {
static const int initialSize = 2048;
static int charsWritten = 0;

va_list argsForLen, argsForPrint;
va_start(argsForLen, format);
va_copy(argsForPrint, argsForLen);

if (charsWritten == 0) {
assert(cmdBuf == NULL);
cmdBuf = (char*)chpl_mem_allocMany(initialSize, sizeof(char),
CHPL_RT_MD_COMMAND_BUFFER, -1, 0);
}

va_list argsForLen, argsForPrint;
va_start(argsForLen, format);
va_copy(argsForPrint, argsForLen);

const int addedLen = vsnprintf(NULL, 0, format, argsForLen);
va_end(argsForLen);
int newLen = charsWritten + addedLen;
Expand Down

0 comments on commit 47ec125

Please sign in to comment.