logging: ignore -Wundef in log.c
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 28 Oct 2019 18:40:16 +0000 (14:40 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 31 Oct 2019 18:11:59 +0000 (14:11 -0400)
When building with -Wundef enabled, I get this warning:

    /home/smarchi/src/babeltrace/src/logging/log.c: In function ‘put_tag’:
    /home/smarchi/src/babeltrace/src/logging/log.c:455:15: error: "_BT_LOG_MESSAGE_FORMAT_MASK__TAG" is not defined, evaluates to 0 [-Werror=undef]
      _PP_CONCAT_3(_BT_LOG_MESSAGE_FORMAT_MASK_, _, field)
                   ^
    /home/smarchi/src/babeltrace/src/logging/log.c:350:30: note: in definition of macro ‘_PP_PASTE_3’
     #define _PP_PASTE_3(a, b, c) a ## b ## c
                                  ^
    /home/smarchi/src/babeltrace/src/logging/log.c:455:2: note: in expansion of macro ‘_PP_CONCAT_3’
      _PP_CONCAT_3(_BT_LOG_MESSAGE_FORMAT_MASK_, _, field)
      ^~~~~~~~~~~~
    /home/smarchi/src/babeltrace/src/logging/log.c:470:3: note: in expansion of macro ‘_BT_LOG_MESSAGE_FORMAT_MASK’
      (_BT_LOG_MESSAGE_FORMAT_MASK(field) & _BT_LOG_MESSAGE_FORMAT_FIELDS(format))
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/smarchi/src/babeltrace/src/logging/log.c:1151:6: note: in expansion of macro ‘_BT_LOG_MESSAGE_FORMAT_CONTAINS’
     #if !_BT_LOG_MESSAGE_FORMAT_CONTAINS(TAG, BT_LOG_MESSAGE_TAG_FORMAT)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That code comes from zf_log and is a big mess of macros, I don't know
how to fix that.  However, I'd like to enable -Wundef, given that it has
found a relatively important bug (see commit 9103e903a8 "Fix: define
macros for logging levels").  So, silence -Wundef just for that
particular spot.

Change-Id: I42fece6a04c3715daea873683c350b2987c500e5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2278
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
configure.ac
src/logging/log.c

index c8012d91e0fb0f286a733403eb6ba49a13e9c02c..b5090b39d4cc80d29200578e48e0fc59bcf5f369 100644 (file)
@@ -671,7 +671,6 @@ AX_COMPILER_FLAGS(
                -Wno-packed dnl
                -Wno-pointer-arith dnl
                -Wno-format-nonliteral dnl
-               -Wno-undef dnl
                -Wno-double-promotion dnl
                -Wno-cast-align dnl
        ])
index 093930d222ff0dff47b22a6c748af5c8e30653c7..349204e8148fa24f047dc6fd0b98ff39f6017d57 100644 (file)
@@ -1148,9 +1148,21 @@ static void put_ctx(bt_log_message *const msg)
 static void put_tag(bt_log_message *const msg, const char *const tag)
 {
        _PP_MAP(_BT_LOG_MESSAGE_FORMAT_INIT, BT_LOG_MESSAGE_TAG_FORMAT)
+
+/*
+ * This generates a -Wundef warning.  The issue was reported upstream:
+ *
+ *   https://github.com/wonder-mice/zf_log/issues/40
+ *
+ * but there's not much we can do here, so just silence it.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wundef"
 #if !_BT_LOG_MESSAGE_FORMAT_CONTAINS(TAG, BT_LOG_MESSAGE_TAG_FORMAT)
        VAR_UNUSED(tag);
 #endif
+#pragma GCC diagnostic pop
+
 #if !_BT_LOG_MESSAGE_FORMAT_FIELDS(BT_LOG_MESSAGE_TAG_FORMAT)
        VAR_UNUSED(msg);
 #else
This page took 0.025873 seconds and 4 git commands to generate.