When building with gcc at -O2, I get:
CC debug-info.lo
/home/simark/src/babeltrace/src/plugins/lttng-utils/debug-info/debug-info.c: In function ‘debug_info_msg_iter_next’:
/home/simark/src/babeltrace/src/plugins/lttng-utils/debug-info/debug-info.c:181:19: error: potential null pointer dereference [-Werror=null-dereference]
181 | bt_logging_level log_level = bin->log_level;
| ^~~~~~~~~
Putting a BT_ASSERT(bin) convinces gcc that bin won't be NULL, and if it
ever happens to be NULL (because we mess up), the crash will be
smoother.
This is the last instance of the -Wnull-dereference, so we can remove
-Wno-null-dereference from configure.ac.
Change-Id: I8bf5c6a0cf231e8516ece14be7b3fcf6f5eaa2ad
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2270
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
-Wno-redundant-decls dnl
-Wno-logical-op dnl
-Wno-shadow dnl
- -Wno-null-dereference dnl
-Wno-double-promotion dnl
-Wno-cast-align dnl
])
int ret;
struct debug_info_source *debug_info_src = NULL;
struct source_location *src_loc = NULL;
- bt_logging_level log_level = bin->log_level;
+ bt_logging_level log_level;
+
+ BT_ASSERT(bin);
+
+ log_level = bin->log_level;
debug_info_src = g_new0(struct debug_info_source, 1);