cleanup: fix incorrect gcc fallthrough warnings master
authorErica Bugden <ebugden@efficios.com>
Mon, 11 Nov 2024 19:59:10 +0000 (14:59 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Nov 2024 20:26:31 +0000 (15:26 -0500)
commit65bc1bc5cb14cad10dec315829a17c2422436957
treee9e7fdce8caafa4531aa8a3a940e574c00c6fe6f
parent7baafa609201eee4a5558bf8d5944cb6234545c8
cleanup: fix incorrect gcc fallthrough warnings

...by adding explicit aborts. The `BT_ASSERT_POST_DEV` macros in these
cases will always lead to stopping execution because of the `false`
condition, but the gcc compiler does not always catch this.

In commit 49bd74f4da37 ("ccv: adjust for MIP 1") explicit aborts were
added to the more complex cases in the same switch statement. With gcc
11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04), the incorrect warnings are also
generated for simpler cases. For example:

    lib/graph/iterator.c: In function ‘assert_post_dev_clock_classes_are_compatible_one’:
    ../src/lib/assert-cond-base.h:94:20: error: this statement may fall through [-Werror=implicit-fallthrough=]
       94 |                 if (!(_cond)) {                                         \
          |                    ^
    ../src/lib/assert-cond-base.h:123:9: note: in expansion of macro ‘_BT_ASSERT_COND’
      123 |         _BT_ASSERT_COND("post", _func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__);
          |         ^~~~~~~~~~~~~~~
    ../src/lib/assert-cond-base.h:136:9: note: in expansion of macro ‘BT_ASSERT_POST’
      136 |         BT_ASSERT_POST(_func, _id_suffix, (_cond), _fmt, ##__VA_ARGS__)
          |         ^~~~~~~~~~~~~~
    lib/graph/iterator.c:723:25: note: in expansion of macro ‘BT_ASSERT_POST_DEV’
      723 |                         BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
          |                         ^~~~~~~~~~~~~~~~~~
    lib/graph/iterator.c:734:17: note: here
      734 |                 case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_KNOWN_GOT_NO_CLOCK_CLASS:
          |                 ^~~~

Add explicit aborts to the simpler cases as well so the warnings are
not generated.

Change-Id: Ib2547e7abff856bb820e736f2be695b03be6a5e3
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13527
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/graph/iterator.c
This page took 0.02491 seconds and 4 git commands to generate.