From d6625d51116d4de58d5554ec44304978b09a3ee0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 18:44:31 +0100 Subject: [PATCH] settings: drop redundant range check from NMSettingBridgePort::verify() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit priv->path_cost and priv->priority can only be set as GObject properties, which already does the same range check. Hence, the checks are never reached. This also avoids a compiler warning: libnm-core/nm-setting-bridge-port.c: In function ‘verify’: libnm-core/nm-setting-bridge-port.c:132:22: error: comparison is always false due to limited range of data type [-Werror=type-limits] if (priv->path_cost > BR_MAX_PATH_COST) { ^ (cherry picked from commit 31c0c66c0e8c23a2428b3d0f5dcf7e32c71d3b92) --- libnm-core/nm-setting-bridge-port.c | 31 ++--------------------------- libnm-util/nm-setting-bridge-port.c | 30 ++-------------------------- 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/libnm-core/nm-setting-bridge-port.c b/libnm-core/nm-setting-bridge-port.c index 331fa5aea0..0116a8364c 100644 --- a/libnm-core/nm-setting-bridge-port.c +++ b/libnm-core/nm-setting-bridge-port.c @@ -115,33 +115,6 @@ nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting) static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting); - - if (priv->priority > BR_MAX_PORT_PRIORITY) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%d' is not a valid value for the property (should be <= %d)"), - priv->priority, BR_MAX_PORT_PRIORITY); - g_prefix_error (error, "%s.%s: ", - NM_SETTING_BRIDGE_PORT_SETTING_NAME, - NM_SETTING_BRIDGE_PORT_PRIORITY); - return FALSE; - } - - if (priv->path_cost > BR_MAX_PATH_COST) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%d' is not a valid value for the property (should be <= %d)"), - priv->path_cost, BR_MAX_PATH_COST); - g_prefix_error (error, "%s.%s: ", - NM_SETTING_BRIDGE_PORT_SETTING_NAME, - NM_SETTING_BRIDGE_PORT_PATH_COST); - return FALSE; - } - - if (connection) { NMSettingConnection *s_con; const char *slave_type; @@ -202,10 +175,10 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_PRIORITY: - priv->priority = (guint16) (g_value_get_uint (value) & 0xFFFF); + priv->priority = g_value_get_uint (value); break; case PROP_PATH_COST: - priv->path_cost = (guint16) (g_value_get_uint (value) & 0xFFFF); + priv->path_cost = g_value_get_uint (value); break; case PROP_HAIRPIN_MODE: priv->hairpin_mode = g_value_get_boolean (value); diff --git a/libnm-util/nm-setting-bridge-port.c b/libnm-util/nm-setting-bridge-port.c index 3d671ae376..24417059e2 100644 --- a/libnm-util/nm-setting-bridge-port.c +++ b/libnm-util/nm-setting-bridge-port.c @@ -145,32 +145,6 @@ nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting) static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { - NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting); - - if (priv->priority > BR_MAX_PORT_PRIORITY) { - g_set_error (error, - NM_SETTING_BRIDGE_PORT_ERROR, - NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, - _("'%d' is not a valid value for the property (should be <= %d)"), - priv->priority, BR_MAX_PORT_PRIORITY); - g_prefix_error (error, "%s.%s: ", - NM_SETTING_BRIDGE_PORT_SETTING_NAME, - NM_SETTING_BRIDGE_PORT_PRIORITY); - return FALSE; - } - - if (priv->path_cost > BR_MAX_PATH_COST) { - g_set_error (error, - NM_SETTING_BRIDGE_PORT_ERROR, - NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY, - _("'%d' is not a valid value for the property (should be <= %d)"), - priv->path_cost, BR_MAX_PATH_COST); - g_prefix_error (error, "%s.%s: ", - NM_SETTING_BRIDGE_PORT_SETTING_NAME, - NM_SETTING_BRIDGE_PORT_PATH_COST); - return FALSE; - } - return TRUE; } @@ -204,10 +178,10 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_PRIORITY: - priv->priority = (guint16) (g_value_get_uint (value) & 0xFFFF); + priv->priority = g_value_get_uint (value); break; case PROP_PATH_COST: - priv->path_cost = (guint16) (g_value_get_uint (value) & 0xFFFF); + priv->path_cost = g_value_get_uint (value); break; case PROP_HAIRPIN_MODE: priv->hairpin_mode = g_value_get_boolean (value);