Commit 7881904e authored by Lubomir Rintel's avatar Lubomir Rintel 🥕
Browse files

all: avoid useless use of NM_IN_STRSET()

Sometimes NM_IN_STRSET() is used for comparing two strings. This hampers
readability, making it look like the argument, if it's a macro, expands
to multiple values.

Other than that it's just odd and useless.
parent 3ce34510
Pipeline #656968 failed with stages
in 7 minutes
......@@ -175,7 +175,7 @@ update_connection(NMDevice *device, NMConnection *connection)
gs_free char *value = NULL;
char *p;
if (NM_IN_STRSET(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE))
if (nm_streq(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE))
continue;
value =
......
......@@ -8862,8 +8862,8 @@ unmanaged_on_quit(NMDevice *self)
/* the only exception are IPv4 shared connections. We unmanage them on quit. */
connection = nm_device_get_applied_connection(self);
if (connection) {
if (NM_IN_STRSET(nm_utils_get_ip_config_method(connection, AF_INET),
NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
if (nm_streq(nm_utils_get_ip_config_method(connection, AF_INET),
NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
/* shared connections are to be unmangaed. */
return TRUE;
}
......@@ -11866,9 +11866,9 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const
} else {
_dev_ipll6_start(self);
 
if (NM_IN_STRSET(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))
if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_AUTO))
_dev_ipac6_start(self);
else if (NM_IN_STRSET(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED))
else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_SHARED))
_dev_ipshared6_start(self);
else if (nm_streq(method, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_MANAGED;
......@@ -16595,7 +16595,7 @@ _hw_addr_get_cloned(NMDevice *self,
}
addr_out = g_strdup(addr);
type_out = HW_ADDR_TYPE_PERMANENT;
} else if (NM_IN_STRSET(addr, NM_CLONED_MAC_RANDOM)) {
} else if (nm_streq(addr, NM_CLONED_MAC_RANDOM)) {
if (priv->hw_addr_type == HW_ADDR_TYPE_GENERATED) {
/* hm, we already use a generate MAC address. Most certainly, that is from the same
* activation request, so we should not create a new random address, instead keep
......@@ -16616,7 +16616,7 @@ _hw_addr_get_cloned(NMDevice *self,
 
addr_out = g_steal_pointer(&hw_addr_generated);
type_out = HW_ADDR_TYPE_GENERATED;
} else if (NM_IN_STRSET(addr, NM_CLONED_MAC_STABLE)) {
} else if (nm_streq(addr, NM_CLONED_MAC_STABLE)) {
NMUtilsStableType stable_type;
const char *stable_id;
 
......@@ -17089,7 +17089,7 @@ nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean
 
method = nm_device_get_effective_ip_config_method(self, addr_family);
if (IS_IPv4) {
if (NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
nm_clear_pointer(&priv->hostname_resolver_x[IS_IPv4], _hostname_resolver_free);
NM_SET_OUT(out_wait, FALSE);
return NULL;
......
......@@ -2826,7 +2826,7 @@ state_changed(NMDeviceIwd *self, const char *new_state)
/* Don't allow new connection until iwd exits disconnecting and no
* Connect callback is pending.
*/
if (!priv->iwd_autoconnect && NM_IN_STRSET(new_state, "disconnected")) {
if (!priv->iwd_autoconnect && nm_streq(new_state, "disconnected")) {
priv->nm_autoconnect = TRUE;
if (!can_connect)
nm_device_emit_recheck_auto_activate(device);
......
......@@ -567,7 +567,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family)
method = nm_utils_get_ip_config_method(connection, addr_family);
/* We may have an address assigned by the group owner */
if (IS_IPv4 && NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) && priv->group_iface
if (IS_IPv4 && nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) && priv->group_iface
&& !nm_supplicant_interface_get_p2p_group_owner(priv->group_iface)) {
in_addr_t addr;
guint8 plen;
......@@ -591,7 +591,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family)
}
if (IS_IPv4)
indicate_addressing_running = NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
indicate_addressing_running = nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
else {
indicate_addressing_running = NM_IN_STRSET(method,
NM_SETTING_IP6_CONFIG_METHOD_AUTO,
......
......@@ -3399,7 +3399,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family)
method = nm_utils_get_ip_config_method(nm_device_get_applied_connection(device), addr_family);
if (NM_IS_IPv4(addr_family))
indicate_addressing_running = NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
indicate_addressing_running = nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
else {
indicate_addressing_running = NM_IN_STRSET(method,
NM_SETTING_IP6_CONFIG_METHOD_AUTO,
......
......@@ -721,7 +721,7 @@ _stage3_ip_config_start_on_idle(NMModem *self, int addr_family)
method = nm_utils_get_ip_config_method(connection, addr_family);
if (IS_IPv4 ? NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
if (IS_IPv4 ? nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
: NM_IN_STRSET(method,
NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) {
......
......@@ -182,13 +182,13 @@ do_notify:
s_err = g_dbus_error_get_remote_error(error);
if (NM_IN_STRSET(s_err, "org.freedesktop.NetworkManager.Device.Failed")) {
if (nm_streq(s_err, "org.freedesktop.NetworkManager.Device.Failed")) {
_LOGi("notify failed with reason: %s", error->message);
success = FALSE;
goto out;
}
if (!NM_IN_STRSET(s_err, "org.freedesktop.DBus.Error.UnknownMethod")) {
if (!nm_streq(s_err, "org.freedesktop.DBus.Error.UnknownMethod")) {
/* Some unexpected error. We treat that as a failure. In particular,
* the daemon will fail the request if ACD fails. This causes nm-dhcp-helper
* to fail, which in turn causes dhclient to send a DECLINE. */
......
......@@ -314,7 +314,7 @@ private_server_allow_mechanism(GDBusAuthObserver *observer,
const char *mechanism,
gpointer user_data)
{
return NM_IN_STRSET(mechanism, "EXTERNAL");
return nm_streq(mechanism, "EXTERNAL");
}
static void
......
......@@ -7439,7 +7439,7 @@ _dbus_set_property_audit_log_get_args(NMDBusObject *obj,
property_name,
g_variant_get_boolean(value) ? "on" : "off"));
}
if (NM_IN_STRSET(property_name, NM_MANAGER_GLOBAL_DNS_CONFIGURATION)) {
if (nm_streq(property_name, NM_MANAGER_GLOBAL_DNS_CONFIGURATION)) {
return NM_MANAGER_GLOBAL_DNS_CONFIGURATION;
}
......
......@@ -9146,7 +9146,7 @@ _svUnescape(const char *str, char **to_free)
g_assert(!to_free2);
g_assert_cmpstr(s, ==, "");
g_assert(!*to_free);
} else if (NM_IN_STRSET(str, "$'x\\U0'")) {
} else if (nm_streq(str, "$'x\\U0'")) {
g_assert_cmpstr(s2, ==, NULL);
g_assert(!to_free2);
g_assert_cmpstr(s, ==, "x");
......
......@@ -1267,7 +1267,7 @@ nms_keyfile_plugin_init(NMSKeyfilePlugin *plugin)
/* no duplicates */
if (NM_IN_STRSET(priv->dirname_libs[0], priv->dirname_etc, priv->dirname_run))
nm_clear_g_free(&priv->dirname_libs[0]);
if (NM_IN_STRSET(priv->dirname_etc, priv->dirname_run))
if (nm_streq(priv->dirname_etc, priv->dirname_run))
nm_clear_g_free(&priv->dirname_etc);
nm_assert(!priv->dirname_libs[0] || priv->dirname_libs[0][0] == '/');
......
......@@ -293,7 +293,7 @@ security_from_vardict(GVariant *security)
flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X;
else if (NM_IN_STRSET(v, "sae", "ft-sae"))
flags |= NM_802_11_AP_SEC_KEY_MGMT_SAE;
else if (NM_IN_STRSET(v, "owe"))
else if (nm_streq(v, "owe"))
flags |= NM_802_11_AP_SEC_KEY_MGMT_OWE;
else if (NM_IN_STRSET(v, "wpa-eap-suite-b-192", "wpa-ft-eap-sha384"))
flags |= NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192;
......@@ -303,9 +303,9 @@ security_from_vardict(GVariant *security)
if (g_variant_lookup(security, "Pairwise", "^a&s", &array)) {
for (i = 0; (v = array[i]); i++) {
if (NM_IN_STRSET(v, "tkip"))
if (nm_streq(v, "tkip"))
flags |= NM_802_11_AP_SEC_PAIR_TKIP;
else if (NM_IN_STRSET(v, "ccmp"))
else if (nm_streq(v, "ccmp"))
flags |= NM_802_11_AP_SEC_PAIR_CCMP;
}
g_free(array);
......
......@@ -335,11 +335,11 @@ _bond_get_option_normalized(NMSettingBond *self, const char *option, gboolean ge
value = _bond_get_option(self, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP);
if (!value)
value = _bond_get_option(self, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA);
} else if (NM_IN_STRSET(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE)) {
} else if (nm_streq(option, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE)) {
/* "active_slave" is deprecated, and an alias for "primary". The property
* itself always normalizes to %NULL. */
value = NULL;
} else if (NM_IN_STRSET(option, NM_SETTING_BOND_OPTION_PRIMARY)) {
} else if (nm_streq(option, NM_SETTING_BOND_OPTION_PRIMARY)) {
/* "active_slave" is deprecated, and an alias for "primary". */
value = _bond_get_option(self, NM_SETTING_BOND_OPTION_PRIMARY);
if (!value)
......
......@@ -1258,7 +1258,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
if (connection)
goto after_interface_name;
iface_type = NMU_IFACE_ANY;
} else if (NM_IN_STRSET(ovs_iface_type, "patch")) {
} else if (nm_streq(ovs_iface_type, "patch")) {
/* this interface type is internal to OVS. */
iface_type = NMU_IFACE_OVS;
} else {
......
......@@ -3417,7 +3417,7 @@ nm_ip_routing_rule_from_string(const char *str,
/* iproute2 matches keywords with any partial prefix. We don't allow
* for that flexibility. */
if (NM_IN_STRSET(word0, "from")) {
if (nm_streq(word0, "from")) {
if (!word1)
continue;
if (word_from)
......@@ -3425,7 +3425,7 @@ nm_ip_routing_rule_from_string(const char *str,
word_from = word1;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "to")) {
if (nm_streq(word0, "to")) {
if (!word1)
continue;
if (word_to)
......@@ -3433,7 +3433,7 @@ nm_ip_routing_rule_from_string(const char *str,
word_to = word1;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "not")) {
if (nm_streq(word0, "not")) {
/* we accept multiple "not" specifiers. "not not" still means
* not. */
val_invert = TRUE;
......@@ -3477,7 +3477,7 @@ nm_ip_routing_rule_from_string(const char *str,
goto next_fail_word1_invalid_value;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "ipproto")) {
if (nm_streq(word0, "ipproto")) {
if (!word1)
continue;
if (i64_ipproto != -1)
......@@ -3487,7 +3487,7 @@ nm_ip_routing_rule_from_string(const char *str,
goto next_fail_word1_invalid_value;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "sport")) {
if (nm_streq(word0, "sport")) {
if (!word1)
continue;
if (i64_sport_start != -1)
......@@ -3496,7 +3496,7 @@ nm_ip_routing_rule_from_string(const char *str,
goto next_fail_word1_invalid_value;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "dport")) {
if (nm_streq(word0, "dport")) {
if (!word1)
continue;
if (i64_dport_start != -1)
......@@ -3505,7 +3505,7 @@ nm_ip_routing_rule_from_string(const char *str,
goto next_fail_word1_invalid_value;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "fwmark")) {
if (nm_streq(word0, "fwmark")) {
if (!word1)
continue;
if (i64_fwmark != -1)
......@@ -3532,7 +3532,7 @@ nm_ip_routing_rule_from_string(const char *str,
word_iifname = word1;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "oif")) {
if (nm_streq(word0, "oif")) {
if (!word1)
continue;
if (word_oifname)
......@@ -3550,7 +3550,7 @@ nm_ip_routing_rule_from_string(const char *str,
goto next_fail_word1_invalid_value;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "uidrange")) {
if (nm_streq(word0, "uidrange")) {
if (!word1)
continue;
if (uid_range_has)
......@@ -3572,7 +3572,7 @@ nm_ip_routing_rule_from_string(const char *str,
uid_range_has = TRUE;
goto next_words_consumed;
}
if (NM_IN_STRSET(word0, "type")) {
if (nm_streq(word0, "type")) {
if (!word1)
continue;
if (i_action >= 0)
......
......@@ -934,7 +934,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
if (NM_IN_STRSET(wifi_mode, NM_SETTING_WIRELESS_MODE_MESH)
if (nm_streq(wifi_mode, NM_SETTING_WIRELESS_MODE_MESH)
&& !NM_IN_STRSET(priv->key_mgmt, "none", "sae")) {
g_set_error(error,
NM_CONNECTION_ERROR,
......
......@@ -1092,9 +1092,9 @@ test_in_strset_ascii_case(void)
g_assert(!NM_IN_STRSET_ASCII_CASE(x, "b"));
x = "b";
g_assert(NM_IN_STRSET(x, "b"));
g_assert(nm_streq(x, "b"));
g_assert(NM_IN_STRSET_ASCII_CASE(x, "b"));
g_assert(!NM_IN_STRSET(x, "B"));
g_assert(!nm_streq(x, "B"));
g_assert(NM_IN_STRSET_ASCII_CASE(x, "B"));
}
......
......@@ -10026,7 +10026,7 @@ handle_udev_event(NMUdevClient *udev_client, struct udev_device *udevice, gpoint
if (NM_IN_STRSET(action, "add", "move"))
udev_device_added(platform, udevice);
else if (NM_IN_STRSET(action, "remove"))
else if (nm_streq(action, "remove"))
udev_device_removed(platform, udevice);
}
......
......@@ -143,13 +143,13 @@ nm_vpn_get_secret_names(const char *service_type)
return _VPN_PASSWORD_LIST({"password", N_("Password")}, );
}
if (NM_IN_STRSET(type, "openvpn")) {
if (nm_streq(type, "openvpn")) {
return _VPN_PASSWORD_LIST({"password", N_("Password")},
{"cert-pass", N_("Certificate password")},
{"http-proxy-password", N_("HTTP proxy password")}, );
}
if (NM_IN_STRSET(type, "vpnc")) {
if (nm_streq(type, "vpnc")) {
return _VPN_PASSWORD_LIST({"Xauth password", N_("Password")},
{"IPSec secret", N_("Group password")}, );
};
......@@ -159,7 +159,7 @@ nm_vpn_get_secret_names(const char *service_type)
{"pskvalue", N_("Group password")}, );
};
if (NM_IN_STRSET(type, "openconnect")) {
if (nm_streq(type, "openconnect")) {
return _VPN_PASSWORD_LIST({"gateway", N_("Gateway")},
{"cookie", N_("Cookie")},
{"gwcert", N_("Gateway certificate hash")}, );
......
......@@ -917,7 +917,7 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info,
nm_assert(property_info->setting_info
== &nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_WIRED]
&& NM_IN_STRSET(property_info->property_name, NM_SETTING_WIRED_S390_OPTIONS));
&& nm_streq(property_info->property_name, NM_SETTING_WIRED_S390_OPTIONS));
nm_assert(property_info->property_type->set_fcn == _set_fcn_optionlist);
strdict = g_value_get_boxed(&val);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment