From 64b062753fe5593f890f714d09113247bfb7d757 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 13 Dec 2024 09:48:30 +0100 Subject: [PATCH] connection: warn if return from nm_connection_normalize() is unused If we try to normalize a connection, we generally rely on it being already valid and be normalized afterwards. There's one particular case (nmcli interactive add/edit), where we call it repeatedly on a best-effort basis and don't care about the failures. Disable the warning there. --- src/libnm-core-public/nm-connection.h | 14 ++++++++++---- src/nmcli/connections.c | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libnm-core-public/nm-connection.h b/src/libnm-core-public/nm-connection.h index ff3e0f924a..bf1dd594cf 100644 --- a/src/libnm-core-public/nm-connection.h +++ b/src/libnm-core-public/nm-connection.h @@ -152,10 +152,16 @@ gboolean nm_connection_diff(NMConnection *a, gboolean nm_connection_verify(NMConnection *connection, GError **error); NM_AVAILABLE_IN_1_2 gboolean nm_connection_verify_secrets(NMConnection *connection, GError **error); -gboolean nm_connection_normalize(NMConnection *connection, - GHashTable *parameters, - gboolean *modified, - GError **error); +#ifndef __GI_SCANNER__ +#ifdef NETWORKMANAGER_COMPILATION +_nm_warn_unused_result +#endif +#endif + gboolean + nm_connection_normalize(NMConnection *connection, + GHashTable *parameters, + gboolean *modified, + GError **error); const char *nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints); diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index bccec3a1a2..6dbbfff22b 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -6013,7 +6013,9 @@ read_properties: * Keep asking until there's no more things to ask for. */ do { /* This ensures all settings that make sense are present. */ + NM_PRAGMA_WARNING_DISABLE("-Wunused-result") nm_connection_normalize(connection, NULL, NULL, NULL); + NM_PRAGMA_WARNING_REENABLE } while (nmc->ask && questionnaire_one_optional(nmc, connection)); /* Mandatory settings. No good reason to check this other than guarding the user