From: Simon Marchi Date: Mon, 28 Oct 2019 18:40:16 +0000 (-0400) Subject: logging: ignore -Wundef in log.c X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=156184d68ce8a9338e042908c522255e3eed800d logging: ignore -Wundef in log.c 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2278 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- diff --git a/configure.ac b/configure.ac index c8012d91..b5090b39 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]) diff --git a/src/logging/log.c b/src/logging/log.c index 093930d2..349204e8 100644 --- a/src/logging/log.c +++ b/src/logging/log.c @@ -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