From d18e7a106511739f08d95a548ef82073843384e9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 27 Oct 2019 21:52:47 -0400 Subject: [PATCH] Fix: ctf-writer: field_type_common_has_known_id always returns true MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I get this when building with gcc: CC event.lo In file included from /home/simark/src/babeltrace/src/ctf-writer/event.h:42, from /home/simark/src/babeltrace/src/ctf-writer/event.c:45: /home/simark/src/babeltrace/src/ctf-writer/fields.h: In function ‘field_type_common_has_known_id’: /home/simark/src/babeltrace/src/ctf-writer/fields.h:291:53: error: logical ‘or’ of collectively exhaustive tests is always true [-Werror=logical-op] 291 | return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN || | Indeed, the logical expression there always returns true. Change the || for a &&, which is what I think was meant here. Change-Id: I0dbfb074e97b96b8f727f85628a544c412d2221c Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2272 Reviewed-by: Francis Deslauriers --- configure.ac | 1 - src/ctf-writer/fields.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 120fb28c..b9edbf54 100644 --- a/configure.ac +++ b/configure.ac @@ -675,7 +675,6 @@ AX_COMPILER_FLAGS( -Wno-missing-prototypes dnl -Wno-missing-declarations dnl -Wno-redundant-decls dnl - -Wno-logical-op dnl -Wno-double-promotion dnl -Wno-cast-align dnl ]) diff --git a/src/ctf-writer/fields.h b/src/ctf-writer/fields.h index bab2e581..5ff9ceb7 100644 --- a/src/ctf-writer/fields.h +++ b/src/ctf-writer/fields.h @@ -288,7 +288,7 @@ BT_ASSERT_DBG_FUNC static inline bool field_type_common_has_known_id( struct bt_ctf_field_type_common *ft) { - return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN || + return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN && (int) ft->id < BT_CTF_FIELD_TYPE_ID_NR; } -- 2.34.1