Skip to content

Commit 160b790

Browse files
committed
Fix vfprintf issue with for the new format-overflow warning
1 parent 743e792 commit 160b790

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

bundles/logging/log_admin/gtest/src/LogAdminTestSuite.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ static void logSinkFunction(void *handle, celix_log_level_e level, long logServi
290290
EXPECT_STREQ("test::Log1", logServiceName);
291291
}
292292

293-
vfprintf(stdout, format, formatArgs);
294-
295-
fprintf(stdout, "\n");
293+
if (format) {
294+
vfprintf(stdout, format, formatArgs);
295+
fprintf(stdout, "\n");
296+
}
296297
}
297298

298299
TEST_F(LogBundleTestSuite, LogServiceAndSink) {

bundles/logging/log_helper/gtest/src/LogHelperTestSuite.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ TEST_F(LogHelperTestSuite, LogToLogSvc) {
6969
logSvc.vlogDetails= [](void *handle, celix_log_level_e, const char*, const char*, int, const char *format, va_list formatArgs) {
7070
auto* c = static_cast<std::atomic<size_t>*>(handle);
7171
c->fetch_add(1);
72-
vfprintf(stderr, format, formatArgs);
73-
fprintf(stderr, "\n");
72+
if (format) {
73+
vfprintf(stderr, format, formatArgs);
74+
fprintf(stderr, "\n");
75+
}
7476
};
7577

7678
auto* props = celix_properties_create();

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def build_requirements(self):
222222
if self.options.enable_testing:
223223
self.test_requires("gtest/1.17.0")
224224
if self.options.enable_ccache:
225-
self.build_requires("ccache/4.7.4")
225+
self.build_requires("ccache/[>=4.8 <=4.10.2]")
226226
if self.options.enable_benchmarking:
227227
self.test_requires("benchmark/[>=1.6.2]")
228228

libs/framework/gtest/src/ScheduledEventTestSuite.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,10 @@ TEST_F(ScheduledEventTestSuite, ScheduledEventTimeoutLogTest) {
720720
output = stderr;
721721
}
722722
fprintf(output, "%s: ", celix_logLevel_toString(level));
723-
vfprintf(output, format, args);
724-
fprintf(output, "\n");
723+
if (format) {
724+
vfprintf(output, format, args);
725+
fprintf(output, "\n");
726+
}
725727
};
726728
celix_framework_setLogCallback(fw->getCFramework(), &logCount, logCallback);
727729

libs/utils/src/celix_log_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void celix_logUtils_vLogToStdout(const char *logName, celix_log_level_e level, c
8686
static pthread_mutex_t globalMutex = PTHREAD_MUTEX_INITIALIZER;
8787

8888
void celix_logUtils_vLogToStdoutDetails(const char *logName, celix_log_level_e level, const char* file, const char* function, int line, const char *format, va_list formatArgs) {
89-
if (level == CELIX_LOG_LEVEL_DISABLED) {
89+
if (format == NULL || level == CELIX_LOG_LEVEL_DISABLED) {
9090
//silently ignore
9191
return;
9292
}

0 commit comments

Comments
 (0)