debug-info: fix one -Wnull-dereference warning
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 28 Oct 2019 01:20:05 +0000 (21:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Oct 2019 19:14:53 +0000 (15:14 -0400)
commitb079debfe85c962d2d6a050a5ab4e2343a5919eb
treecad75bbc595b4a9e914e7c8ca6d1a508d8f2762f
parentb86399bbee3e37b36ef60df8743da17ecea8c5dc
debug-info: fix one -Wnull-dereference warning

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>
configure.ac
src/plugins/lttng-utils/debug-info/debug-info.c
This page took 0.024097 seconds and 4 git commands to generate.