From ceda1ae6ecf09cd6ad521b34b553f78dbe9bec21 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 23 Feb 2023 14:19:10 -0500 Subject: [PATCH] ctf: fix -Wformat-overflow error in ctf-meta-resolve.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix this, seen when building with -O2 with gcc 12.2.1: CXX ctf-meta-resolve.lo In file included from ../../../../../src/logging/comp-logging.h:16, from ctf-meta-resolve.cpp:12: In function 'int pathstr_to_field_path(const char*, ctf_field_path*, resolve_context*)', inlined from 'int resolve_sequence_or_variant_field_class(ctf_field_class*, resolve_context*)' at ctf-meta-resolve.cpp:948:32, inlined from 'int resolve_field_class(ctf_field_class*, resolve_context*)' at ctf-meta-resolve.cpp:1026:54: ../../../../../src/logging/comp-logging.h:18:41: error: '%s' directive argument is null [-Werror=format-overflow=] 18 | #define _BT_COMP_LOG_COMP_PREFIX "[%s] " ../../../../../src/logging/log.h:815:67: note: in definition of macro 'BT_LOG_WRITE' 815 | lvl, tag, __VA_ARGS__); \ | ^~~~~~~~~~~ ../../../../../src/logging/comp-logging.h:23:42: note: in expansion of macro '_BT_COMP_LOG_COMP_PREFIX' 23 | BT_LOG_WRITE((_lvl), BT_LOG_TAG, _BT_COMP_LOG_COMP_PREFIX _fmt, \ | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../../../src/logging/comp-logging.h:83:9: note: in expansion of macro 'BT_COMP_LOG' 83 | BT_COMP_LOG(BT_LOG_DEBUG, (BT_COMP_LOG_SELF_COMP), _fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ ctf-meta-resolve.cpp:650:9: note: in expansion of macro 'BT_COMP_LOGD' 650 | BT_COMP_LOGD("Found field path: path=\"%s\", field-path=\"%s\"", pathstr, | ^~~~~~~~~~~~ Change-Id: Ib311185359a531f3e14bfbbbe6726aa633ceb3e4 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp b/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp index 06fa55f5..5b65414e 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp +++ b/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp @@ -645,7 +645,7 @@ static int pathstr_to_field_path(const char *pathstr, struct ctf_field_path *fie if (BT_LOG_ON_TRACE && ret == 0) { GString *field_path_pretty = ctf_field_path_string(field_path); - const char *field_path_pretty_str = field_path_pretty ? field_path_pretty->str : NULL; + const char *field_path_pretty_str = field_path_pretty ? field_path_pretty->str : "(null)"; BT_COMP_LOGD("Found field path: path=\"%s\", field-path=\"%s\"", pathstr, field_path_pretty_str); -- 2.34.1