ctf: fix -Wformat-overflow warning in ctf-meta-resolve.cpp
Compiling with gcc 13.2.1 (Arch's gcc version as of today) and -O2, I
get:
libtool: compile: ccache g++ -std=c++11 -DHAVE_CONFIG_H -I/home/smarchi/src/babeltrace/include -I../../../../../src -I/home/smarchi/src/babeltrace/src -include common/config.h -I. -I/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata -fvisibility=hidden -fvisibility-inlines-hidden -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -pthread -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wnull-dereference -Wundef -Wredundant-decls -Wshadow -Wjump-misses-init -Wsuggest-attribute=format -Wnested-externs -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Winit-self -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wsuggest-override -Wno-unused-parameter -Wno-sign-compare -Wno-cast-function-type -Wno-missing-field-initializers -Wno-maybe-uninitialized -Werror -g3 -O2 -fmax-errors=1 -fdiagnostics-color=always -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28 -D_GLIBCXX_DEBUG=1 -MT ctf-meta-resolve.lo -MD -MP -MF .deps/ctf-meta-resolve.Tpo -c /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp -fPIC -DPIC -o .libs/ctf-meta-resolve.o
In file included from /home/smarchi/src/babeltrace/src/logging/comp-logging.h:16,
from /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:12:
/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp: In function 'int64_t get_field_paths_lca_index(ctf_field_path*, ctf_field_path*, resolve_context*)':
/home/smarchi/src/babeltrace/src/logging/comp-logging.h:18:41: error: '%s' directive argument is null [-Werror=format-overflow=]
18 | #define _BT_COMP_LOG_COMP_PREFIX "[%s] "
/home/smarchi/src/babeltrace/src/logging/log.h:807:67: note: in definition of macro 'BT_LOG_WRITE'
807 | lvl, tag, __VA_ARGS__); \
| ^~~~~~~~~~~
/home/smarchi/src/babeltrace/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, \
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/smarchi/src/babeltrace/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__)
| ^~~~~~~~~~~
/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:734:9: note: in expansion of macro 'BT_COMP_LOGD'
734 | BT_COMP_LOGD("Finding lowest common ancestor (LCA) between two field paths: "
| ^~~~~~~~~~~~
It is undefined what happens when %s receives NULL. Use the literal
string "(null)" instead of NULL.
Change-Id: I4f53165ff9fc08fb373f7c1cdf87a63f2b792532
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10856
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.026916 seconds and 4 git commands to generate.