From 0c6a98df786f015ae98d9c75af63906d25ff03ef Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 9 Oct 2013 11:26:55 +0200 Subject: [PATCH] libnm-util: do not g_warn when trying to set invalid bond option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nm_setting_bond_add_option returns TRUE or FALSE indicating, whether the bond option was properly set. So, the API already kind of expects invalid values, so there is no reason to warn about it. Co-Authored-By: Jiří Klimeš Signed-off-by: Thomas Haller --- libnm-util/nm-setting-bond.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c index 66eab2cbd..88b1851d4 100644 --- a/libnm-util/nm-setting-bond.c +++ b/libnm-util/nm-setting-bond.c @@ -330,7 +330,9 @@ nm_setting_bond_get_option_by_name (NMSettingBond *setting, const char *name) { g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL); - g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), NULL); + + if (!nm_setting_bond_validate_option (name, NULL)) + return NULL; return g_hash_table_lookup (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name); } @@ -346,18 +348,23 @@ nm_setting_bond_get_option_by_name (NMSettingBond *setting, * (ie [a-zA-Z0-9]). Adding a new name replaces any existing name/value pair * that may already exist. * + * The order of how to set several options is relevant because there are options + * that conflict with each other. + * * Returns: %TRUE if the option was valid and was added to the internal option * list, %FALSE if it was not. **/ -gboolean nm_setting_bond_add_option (NMSettingBond *setting, - const char *name, - const char *value) +gboolean +nm_setting_bond_add_option (NMSettingBond *setting, + const char *name, + const char *value) { NMSettingBondPrivate *priv; g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE); - g_return_val_if_fail (nm_setting_bond_validate_option (name, value), FALSE); - g_return_val_if_fail (value != NULL, FALSE); + + if (!value || !nm_setting_bond_validate_option (name, value)) + return FALSE; priv = NM_SETTING_BOND_GET_PRIVATE (setting); @@ -397,7 +404,9 @@ nm_setting_bond_remove_option (NMSettingBond *setting, gboolean found; g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE); - g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), FALSE); + + if (!nm_setting_bond_validate_option (name, NULL)) + return FALSE; found = g_hash_table_remove (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name); if (found)