From: Simon Marchi Date: Thu, 29 Feb 2024 19:21:36 +0000 (-0500) Subject: cpp-common/bt2: check return value in `CommonVariantField::selectedOption()` X-Git-Url: https://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=b5cc976beb06b03b46950d3b3505d763021bdf7a cpp-common/bt2: check return value in `CommonVariantField::selectedOption()` Instead of ignoring the return value of bt_field_variant_select_option_by_index(), check it with BT_ASSERT_DBG(). This probably won't ever make a difference since bt_field_variant_select_option_by_index() can't fail for now, but it looks better. Change-Id: I2354adfa1358ef0bd77b1d7c6604eef8ccaaa018 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11950 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/src/cpp-common/bt2/field.hpp b/src/cpp-common/bt2/field.hpp index 6853510e..bf470e0b 100644 --- a/src/cpp-common/bt2/field.hpp +++ b/src/cpp-common/bt2/field.hpp @@ -1497,7 +1497,9 @@ public: static_assert(!std::is_const::value, "Not available with `bt2::ConstVariantField`."); - static_cast(bt_field_variant_select_option_by_index(this->libObjPtr(), index)); + const auto status = bt_field_variant_select_option_by_index(this->libObjPtr(), index); + + BT_ASSERT_DBG(status == BT_FIELD_VARIANT_SELECT_OPTION_STATUS_OK); } CommonField selectedOptionField() const noexcept