From 739b8e1740ff0dc8a37aaea4b6e2bbf0cf9dcf70 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 7 Mar 2022 11:28:19 -0500 Subject: [PATCH] fix: warning '-Wformat-overflow' with GCC 11.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Building with GCC 11.2 results in the following warning : In file included from rotation-thread.cpp:11: In function 'int handle_job_queue(rotation_thread_handle*, rotation_thread*, rotation_thread_timer_queue*)', inlined from 'void* thread_rotation(void*)' at rotation-thread.cpp:844:27: ../../../src/common/error.h:139:32: warning: '%s' directive argument is null [-Wformat-overflow=] 139 | fprintf((type) == PRINT_MSG ? stdout : stderr, fmt, ## args); \ | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../src/common/error.h:155:25: note: in expansion of macro '__lttng_print' 155 | __lttng_print(type, \ | ^~~~~~~~~~~~~ ../../../src/common/error.h:195:27: note: in expansion of macro '_ERRMSG' 195 | #define DBG(fmt, args...) _ERRMSG("DBG1", PRINT_DBG, fmt, ## args) | ^~~~~~~ rotation-thread.cpp:587:25: note: in expansion of macro 'DBG' 587 | DBG("Session \"%s\" not found", | ^~~ Use an empty string for the format string if 'session->name' is NULL. Change-Id: Ibe29b43c0e8afd13b1c28770e8f7451340cc1e81 Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/rotation-thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index ecc4c3ea7..a2b92a858 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -585,7 +585,7 @@ int handle_job_queue(struct rotation_thread_handle *handle, session = job->session; if (!session) { DBG("Session \"%s\" not found", - session->name); + session->name != NULL ? session->name : ""); /* * This is a non-fatal error, and we cannot report it to * the user (timer), so just print the error and -- 2.34.1