Call errlogClampConfig only a single time

This commit is contained in:
Simon Rose authored and Andrew Johnson committed 2026-05-27 09:50:20 -05:00
1 parent 73b89cbcd9
commit 70e34a7a2e
1 file changed
+5 -8
+5 -8
View File
@@ -563,8 +563,6 @@ static void errlogInitPvt(void *arg)
{
struct initArgs *pconfig = (struct initArgs *) arg;
errlogClampConfig(pconfig);
epicsThreadId tid = NULL;
epicsThreadOpts topts = EPICS_THREAD_OPTS_INIT;
@@ -620,12 +618,6 @@ void errlogBufResize(struct initArgs config)
return;
}
size_t bufsize = config.bufsize;
size_t maxMsgSize = config.maxMsgSize;
if (errlogClampConfig(&config)) {
fprintf(stderr, "Warning: errlog config clamped from (%zu, %zu) to (%zu, %zu)\n", bufsize, maxMsgSize, config.bufsize, config.maxMsgSize);
}
char *logbuf = calloc(1, config.bufsize);
if (!logbuf) {
fprintf(stderr, ERL_ERROR ": Failed to allocated errlog log buffer.\n");
@@ -665,6 +657,11 @@ int errlogInit2(int bufsize, int maxMsgSize)
if (pvt.atExit)
return 0;
if (errlogClampConfig(&config) && (bufsize != 0)) {
// No sense warning for every call to errlogInit(0)
fprintf(stderr, "Warning: errlog config clamped from (%d, %d) to (%zu, %zu)\n", bufsize, maxMsgSize, config.bufsize, config.maxMsgSize);
}
epicsThreadOnce(&errlogOnceFlag, errlogInitPvt, &config);
if (pvt.errlogInitFailed) {
fprintf(stderr,"errlogInit failed\n");