Skip to content

Commit 9ec1fad

Browse files
Merge branch 'develop' into feature/real-format3
2 parents 50d8d8c + 7f8c35b commit 9ec1fad

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

doc/arkode/guide/source/Usage/MRIStep/User_callable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ Optional inputs for IVP method selection
830830
831831
Select the default MRI method of a given order.
832832
833-
The default order is 3. An order less than 3 or greater than 4 will result in
833+
The default order is 3. An order less than 1 or greater than 4 will result in
834834
using the default.
835835
836836
**Arguments:**

include/sundials/priv/sundials_errors_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,12 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func,
186186
msglen = (size_t)vsnprintf(NULL, (size_t)0, msgfmt, values); /* determine size
187187
of buffer
188188
needed */
189-
msg = (char*)malloc(msglen + 1);
189+
va_end(values);
190+
msg = (char*)malloc(msglen + 1);
191+
va_start(values, sunctx);
190192
vsnprintf(msg, msglen + 1, msgfmt, values);
191-
SUNHandleErrWithMsg(line, func, file, msg, code, sunctx);
192193
va_end(values);
194+
SUNHandleErrWithMsg(line, func, file, msg, code, sunctx);
193195
free(msg);
194196
}
195197

src/sundials/sundials_errors.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ void SUNGlobalFallbackErrHandler(int line, const char* func, const char* file,
9494
char* log_msg = NULL;
9595
char* file_and_line = NULL;
9696

97-
va_start(ap, err_code);
98-
9997
file_and_line = sunCombineFileAndLine(__LINE__, __FILE__);
98+
va_start(ap, err_code);
10099
sunCreateLogMessage(SUN_LOGLEVEL_ERROR, 0, file_and_line,
101100
__func__, "The SUNDIALS SUNContext was corrupt or NULL when an error occurred. As such, error messages have been printed to stderr.",
102101
ap, &log_msg);
102+
va_end(ap);
103103
fprintf(stderr, "%s", log_msg);
104104
free(log_msg);
105105
free(file_and_line);
106106

107107
file_and_line = sunCombineFileAndLine(line, file);
108108
if (msgfmt == NULL) { msgfmt = SUNGetErrMsg(err_code); }
109+
va_start(ap, err_code);
109110
sunCreateLogMessage(SUN_LOGLEVEL_ERROR, 0, file_and_line, func, msgfmt, ap,
110111
&log_msg);
112+
va_end(ap);
111113
fprintf(stderr, "%s", log_msg);
112114
free(log_msg);
113115
free(file_and_line);
114-
115-
va_end(ap);
116116
}

src/sundials/sundials_logger.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ SUNErrCode SUNLogger_QueueMsg(SUNLogger logger, SUNLogLevel lvl,
333333
return retval;
334334
}
335335

336-
va_list args;
337-
va_start(args, msg_txt);
338-
339336
if (logger->queuemsg)
340337
{
338+
va_list args;
339+
va_start(args, msg_txt);
341340
retval = logger->queuemsg(logger, lvl, scope, label, msg_txt, args);
341+
va_end(args);
342342
}
343343
else
344344
{
@@ -347,7 +347,10 @@ SUNErrCode SUNLogger_QueueMsg(SUNLogger logger, SUNLogLevel lvl,
347347
if (sunLoggerIsOutputRank(logger, &rank))
348348
{
349349
char* log_msg = NULL;
350+
va_list args;
351+
va_start(args, msg_txt);
350352
sunCreateLogMessage(lvl, rank, scope, label, msg_txt, args, &log_msg);
353+
va_end(args);
351354

352355
switch (lvl)
353356
{
@@ -372,8 +375,6 @@ SUNErrCode SUNLogger_QueueMsg(SUNLogger logger, SUNLogLevel lvl,
372375
free(log_msg);
373376
}
374377
}
375-
376-
va_end(args);
377378
}
378379
#else
379380
/* silence warnings when all logging is disabled */

test/unit_tests/sundials/test_sundials_errors.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,25 @@ class SUNContextErrFunctionTests : public testing::Test
171171
SUNContext sunctx;
172172
};
173173

174-
void firstHandler(int line, const char* func, const char* file, const char* msg,
175-
SUNErrCode err_code, void* err_user_data, SUNContext sunctx)
174+
static void firstHandler(int line, const char* func, const char* file,
175+
const char* msg, SUNErrCode err_code,
176+
void* err_user_data, SUNContext sunctx)
176177
{
177178
std::vector<int>* order = static_cast<std::vector<int>*>(err_user_data);
178179
order->push_back(0);
179180
}
180181

181-
void secondHandler(int line, const char* func, const char* file, const char* msg,
182-
SUNErrCode err_code, void* err_user_data, SUNContext sunctx)
182+
static void secondHandler(int line, const char* func, const char* file,
183+
const char* msg, SUNErrCode err_code,
184+
void* err_user_data, SUNContext sunctx)
183185
{
184186
std::vector<int>* order = static_cast<std::vector<int>*>(err_user_data);
185187
order->push_back(1);
186188
}
187189

188-
void thirdHandler(int line, const char* func, const char* file, const char* msg,
189-
SUNErrCode err_code, void* err_user_data, SUNContext sunctx)
190+
static void thirdHandler(int line, const char* func, const char* file,
191+
const char* msg, SUNErrCode err_code,
192+
void* err_user_data, SUNContext sunctx)
190193
{
191194
std::vector<int>* order = static_cast<std::vector<int>*>(err_user_data);
192195
order->push_back(2);

0 commit comments

Comments
 (0)