Fix: sessiond: cmd potentially used uninitialized
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 6 Oct 2023 19:17:41 +0000 (15:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 6 Oct 2023 19:17:41 +0000 (15:17 -0400)
commitd4333eb996dec315fb721074c2cf49adee04363b
tree9e6c80514e1f3e8b08fb0fdce4b71794a84d89dc
parent4cf554670aa5c112916c831091e8a40ba4e0b23f
Fix: sessiond: cmd potentially used uninitialized

GCC reports the following warning:

  libtool: compile:  g++ -std=gnu++11 -DHAVE_CONFIG_H -I../../../include -I../../../include -I../../../src -I../../../src -include config.h -I/home/mjeanson/opt/include -I/home/mjeanson/opt/include -DINSTALL_BIN_PATH=\"/home/mjeanson/opt/lib/lttng/libexec\" -DINSTALL_LIB_PATH=\"/home/mjeanson/opt/lib\" -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-aliasing -Wall -Wextra -Wmissing-declarations -Wnull-dereference -Wundef -Wredundant-decls -Wshadow -Wsuggest-attribute=format -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Winit-self -Wno-incomplete-setjmp-declaration -Wno-gnu-folding-constant -Wno-sign-compare -Werror -pthread -g -O2 -MT notification-thread-events.lo -MD -MP -MF .deps/notification-thread-events.Tpo -c notification-thread-events.cpp  -fPIC -DPIC -o .libs/notification-thread-events.o
  In file included from field.hpp:14,
                   from ust-field-convert.hpp:11,
                   from ust-app.hpp:14,
                   from event-notifier-error-accounting.hpp:11,
                   from notification-thread-events.cpp:12:
  ../../../src/vendor/optional.hpp: In function ‘int handle_notification_thread_command(notification_thread_handle*, notification_thread_state*)’:
  ../../../src/vendor/optional.hpp:877:17: error: ‘cmd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    877 |         return &data;
        |                 ^~~~
  notification-thread-events.cpp:3181:45: note: ‘cmd’ was declared here
   3181 |         struct notification_thread_command *cmd;
        |

When failing to pop a command, cmd can indeed be used uninitialized when
jumping to the error label.

Reported-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5e63451ed4936638e9fbe05146f16c86ea2e42e2
src/bin/lttng-sessiond/notification-thread-events.cpp
This page took 0.067004 seconds and 4 git commands to generate.