lttng-sessiond: remove goto in ust_metadata_channel_statedump
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 6 Jan 2022 18:27:55 +0000 (13:27 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 30 Mar 2022 02:40:17 +0000 (22:40 -0400)
commite4589ae2396a53ed0b17251616694afeefba2986
treedeab54f2b47461a266d900c197fdb5d2540455ad
parent0d19be9d7e89fa4ff548592edd6d00a723070ced
lttng-sessiond: remove goto in ust_metadata_channel_statedump

A follow-up patch uses an std::vector declared in the middle of
ust_metadata_channel_statedump. This isn't compatible with the
goto-based error handling, since gotos should not jump over object
initialization (otherwise, the object gets destroyed without having been
constructed).

Moving the std::vector declaration to the beginning of the function
would work, but it would be a pessimization: we would construct an
object that we may not need, depending on the code path taken. We
therefore want to declare (and construct) the std::vector just before
we need it.

Fix this by replacing gotos with return statements.

Also, add a `ret` check after the last lttng_metadata_printf call. If
this call failed, for some reason, we would return an error, but still
set chan->metadata_dumped. That makes this case different than the other
error paths in the function, where chan->metadata_dumped doesn't get
set. Adding the check makes this case like the other ones.

Change-Id: Iba81422a7c3bac96a8d209bba6b4d53ad26b3e4e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-metadata.cpp
This page took 0.024619 seconds and 4 git commands to generate.