From 77c1cf9624e5eb788c47ff3a4feb61f4ed28a48b Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 27 May 2026 23:40:31 +0200 Subject: [PATCH] nmtui: fix wrong use of assertions in bond page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building in release mode the compiler complains with: ../src/nmtui/nmt-page-bond.c: In function ‘other_options_widget_changed’: ../src/nmtui/nmt-page-bond.c:373:13: error: ‘name’ may be used uninitialized [-Werror=maybe-uninitialized] 373 | if (_is_other_option(name)) { | ^~~~~~~~~~~~~~~~~~~~~~ ../src/nmtui/nmt-page-bond.c:357:25: note: ‘name’ was declared here 357 | const char *name; | ^~~~ That happens because "name" is initialized inside an assertion, which is removed in release builds. Assertions must not have side effects. Move the initialization out of the assertion. Fixes: 6a841072ec3b ('nmtui/bond: introduce "other options" list') --- src/nmtui/nmt-page-bond.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nmtui/nmt-page-bond.c b/src/nmtui/nmt-page-bond.c index 962a95096b..eeea0b0b73 100644 --- a/src/nmtui/nmt-page-bond.c +++ b/src/nmtui/nmt-page-bond.c @@ -87,8 +87,10 @@ _bond_update_other_options(NMSettingBond *s_bond, NmtList *list) for (i = 0; i < num_opts; i++) { const char *opt_name; const char *opt_value; + gboolean ret; - nm_assert(nm_setting_bond_get_option(s_bond, i, &opt_name, &opt_value)); + ret = nm_setting_bond_get_option(s_bond, i, &opt_name, &opt_value); + nm_assert(ret); if (_is_other_option(opt_name)) { g_ptr_array_add(arr, g_strdup_printf("%s=%s", opt_name, opt_value)); @@ -355,6 +357,7 @@ other_options_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_d NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE(bond); gs_strfreev char **other_options = NULL; const char *name; + gboolean ret; guint num; guint i; @@ -368,7 +371,8 @@ other_options_widget_changed(GObject *object, GParamSpec *pspec, gpointer user_d again: num = nm_setting_bond_get_num_options(priv->s_bond); for (i = 0; i < num; i++) { - nm_assert(nm_setting_bond_get_option(priv->s_bond, i, &name, NULL)); + ret = nm_setting_bond_get_option(priv->s_bond, i, &name, NULL); + nm_assert(ret); if (_is_other_option(name)) { nm_setting_bond_remove_option(priv->s_bond, name);