...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>
"Expecting no clock class, got one: %![cc-]+K",
actual_clock_cls);
+ /*
+ * GCC gives bogus `-Wimplicit-fallthrough`
+ * warnings: convince it that it's not possible.
+ */
+ bt_common_abort();
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_KNOWN_GOT_NO_CLOCK_CLASS:
if (graph_mip_version == 0) {
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"Expecting a clock class with a specific origin: %![cc-]+K, " EXP_CC_ORIGIN_FMT,
actual_clock_cls, EXP_CC_ORIGIN_VALUES);
+ /*
+ * GCC gives bogus `-Wimplicit-fallthrough`
+ * warnings: convince it that it's not possible.
+ */
+ bt_common_abort();
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_ID_GOT_NO_CLOCK_CLASS:
if (graph_mip_version == 0) {
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"Expecting a clock class, got none: %![expected-cc-]+K",
ref_clock_cls);
+ /*
+ * GCC gives bogus `-Wimplicit-fallthrough`
+ * warnings: convince it that it's not possible.
+ */
+ bt_common_abort();
+
case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_ID_GOT_OTHER_CLOCK_CLASS:
BT_ASSERT_POST_DEV(NEXT_METHOD_NAME,
"clock-class-is-expected", false,