From b2e73635289915f2f6c73772277055741b5b38b6 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Mon, 9 Dec 2024 12:53:58 -0800 Subject: [PATCH] Move va_list setup to top of function Signed-off-by: Anna Rift --- runtime/src/chpl-launcher-common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/chpl-launcher-common.c b/runtime/src/chpl-launcher-common.c index 2045ac922d3b..53378240e0e9 100644 --- a/runtime/src/chpl-launcher-common.c +++ b/runtime/src/chpl-launcher-common.c @@ -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;