ctf: fix -Wformat-overflow error in ctf-meta-resolve.cpp
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 23 Feb 2023 19:19:10 +0000 (14:19 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 23 Feb 2023 20:57:07 +0000 (15:57 -0500)
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 <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp

index 06fa55f5e0180c8ad64bc8b3aae60f66f72be22e..5b65414ee6c3dffe0d837ba60448617c996ff5f1 100644 (file)
@@ -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);
This page took 0.025601 seconds and 4 git commands to generate.