diff options
author | Thomas Haller <thaller@redhat.com> | 2020-02-11 15:17:03 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-02-11 15:23:06 +0100 |
commit | c69d70301703f8174746ccba44ff0f1f1777aada (patch) | |
tree | 5354e14edd0280f49f246c6c6ac80e6c673f1db0 /clients | |
parent | 2e53fd45613cbc45d86f63c9a207dc3cb869698a (diff) | |
download | NetworkManager-c69d70301703f8174746ccba44ff0f1f1777aada.tar.gz |
all: use g_ascii_strcasecmp() instead of the locale dependent strcasecmp()
In all the cases, we don't want to perform locale dependent comparison.
$ sed -i 's/\<strcasecmp\>/g_ascii_\0/g' $(git grep -w -l strcasecmp -- ':(exclude)shared/systemd/' )
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/connections.c | 32 | ||||
-rw-r--r-- | clients/cli/devices.c | 36 | ||||
-rw-r--r-- | clients/cli/general.c | 14 |
3 files changed, 41 insertions, 41 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 6e4e7fd964..7c7e184ff4 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1349,9 +1349,9 @@ nmc_connection_profile_details (NMConnection *connection, NmCli *nmc) const char *base_hdr = _("Connection profile details"); gboolean was_output = FALSE; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = fields_common; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) fields_str = fields_all; else fields_str = nmc->required_fields; @@ -1437,8 +1437,8 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) const char *base_hdr = _("Activate connection details"); gboolean was_output = FALSE; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) { - } else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) { + } else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -1501,7 +1501,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) } /* IP4 */ - if (strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[1]->name) == 0) { + if (g_ascii_strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[1]->name) == 0) { gboolean b1 = FALSE; NMIPConfig *cfg4 = nm_active_connection_get_ip4_config (acon); @@ -1510,7 +1510,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) } /* DHCP4 */ - if (strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[2]->name) == 0) { + if (g_ascii_strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[2]->name) == 0) { gboolean b1 = FALSE; NMDhcpConfig *dhcp4 = nm_active_connection_get_dhcp4_config (acon); @@ -1519,7 +1519,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) } /* IP6 */ - if (strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[3]->name) == 0) { + if (g_ascii_strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[3]->name) == 0) { gboolean b1 = FALSE; NMIPConfig *cfg6 = nm_active_connection_get_ip6_config (acon); @@ -1528,7 +1528,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) } /* DHCP6 */ - if (strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[4]->name) == 0) { + if (g_ascii_strcasecmp (nmc_fields_con_active_details_groups[group_idx]->name, nmc_fields_con_active_details_groups[4]->name) == 0) { gboolean b1 = FALSE; NMDhcpConfig *dhcp6 = nm_active_connection_get_dhcp6_config (acon); @@ -1595,13 +1595,13 @@ split_required_fields_for_con_show (const char *input, if (dot) *dot = '\0'; - is_all = !dot && strcasecmp (s_mutable, "all") == 0; - is_common = !dot && strcasecmp (s_mutable, "common") == 0; + is_all = !dot && g_ascii_strcasecmp (s_mutable, "all") == 0; + is_common = !dot && g_ascii_strcasecmp (s_mutable, "common") == 0; found = FALSE; for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { if ( is_all || is_common - || !strcasecmp (s_mutable, nm_meta_setting_infos[i].setting_name)) { + || !g_ascii_strcasecmp (s_mutable, nm_meta_setting_infos[i].setting_name)) { if (dot) *dot = '.'; g_string_append (str1, s_mutable); @@ -1615,7 +1615,7 @@ split_required_fields_for_con_show (const char *input, for (i = 0; nmc_fields_con_active_details_groups[i]; i++) { if ( is_all || is_common - || !strcasecmp (s_mutable, nmc_fields_con_active_details_groups[i]->name)) { + || !g_ascii_strcasecmp (s_mutable, nmc_fields_con_active_details_groups[i]->name)) { if (dot) *dot = '.'; g_string_append (str2, s_mutable); @@ -1627,9 +1627,9 @@ split_required_fields_for_con_show (const char *input, if (!found) { if (dot) *dot = '.'; - if (!strcasecmp (s_mutable, CON_SHOW_DETAIL_GROUP_PROFILE)) + if (!g_ascii_strcasecmp (s_mutable, CON_SHOW_DETAIL_GROUP_PROFILE)) group_profile = TRUE; - else if (!strcasecmp (s_mutable, CON_SHOW_DETAIL_GROUP_ACTIVE)) + else if (!g_ascii_strcasecmp (s_mutable, CON_SHOW_DETAIL_GROUP_ACTIVE)) group_active = TRUE; else { gs_free char *allowed1 = nm_meta_abstract_infos_get_names_str ((const NMMetaAbstractInfo *const*) nm_meta_setting_infos_editor_p (), NULL); @@ -2056,9 +2056,9 @@ do_connections_show (NmCli *nmc, int argc, char **argv) if (nmc->complete) goto finish; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = NMC_FIELDS_CON_SHOW_COMMON; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; diff --git a/clients/cli/devices.c b/clients/cli/devices.c index a23113339c..964b7dce83 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1430,9 +1430,9 @@ show_device_info (NMDevice *device, NmCli *nmc) const char *base_hdr = _("Device details"); GPtrArray *fields_in_section = NULL; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = NMC_FIELDS_DEV_SHOW_SECTIONS_COMMON; - else if (strcasecmp (nmc->required_fields, "all") == 0) { + else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -1546,7 +1546,7 @@ show_device_info (NMDevice *device, NmCli *nmc) GPtrArray *aps; /* section AP */ - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[4]->name)) { + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[4]->name)) { NMC_OUTPUT_DATA_DEFINE_SCOPED (out); if (state == NM_DEVICE_STATE_ACTIVATED) { @@ -1604,42 +1604,42 @@ show_device_info (NMDevice *device, NmCli *nmc) dhcp6 = nm_device_get_dhcp6_config (device); /* IP4 */ - if (cfg4 && !strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[8]->name)) + if (cfg4 && !g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[8]->name)) was_output = print_ip_config (cfg4, AF_INET, &nmc->nmc_config, section_fld); /* DHCP4 */ - if (dhcp4 && !strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[9]->name)) + if (dhcp4 && !g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[9]->name)) was_output = print_dhcp_config (dhcp4, AF_INET, &nmc->nmc_config, section_fld); /* IP6 */ - if (cfg6 && !strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[10]->name)) + if (cfg6 && !g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[10]->name)) was_output = print_ip_config (cfg6, AF_INET6, &nmc->nmc_config, section_fld); /* DHCP6 */ - if (dhcp6 && !strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[11]->name)) + if (dhcp6 && !g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[11]->name)) was_output = print_dhcp_config (dhcp6, AF_INET6, &nmc->nmc_config, section_fld); /* Bond specific information */ if (NM_IS_DEVICE_BOND (device)) { - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[12]->name)) + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[12]->name)) was_output = print_bond_bridge_info (device, nmc, nmc_fields_dev_show_sections[12]->name, section_fld); } /* Team specific information */ if (NM_IS_DEVICE_TEAM (device)) { - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[13]->name)) + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[13]->name)) was_output = print_team_info (device, nmc, nmc_fields_dev_show_sections[13]->name, section_fld); } /* Bridge specific information */ if (NM_IS_DEVICE_BRIDGE (device)) { - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[14]->name)) + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[14]->name)) was_output = print_bond_bridge_info (device, nmc, nmc_fields_dev_show_sections[14]->name, section_fld); } /* VLAN-specific information */ if ((NM_IS_DEVICE_VLAN (device))) { - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[15]->name)) { + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[15]->name)) { char * vlan_id_str = g_strdup_printf ("%u", nm_device_vlan_get_vlan_id (NM_DEVICE_VLAN (device))); NMDevice *parent = nm_device_vlan_get_parent (NM_DEVICE_VLAN (device)); NMC_OUTPUT_DATA_DEFINE_SCOPED (out); @@ -1664,7 +1664,7 @@ show_device_info (NMDevice *device, NmCli *nmc) } if (NM_IS_DEVICE_BT (device)) { - if (!strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[16]->name)) { + if (!g_ascii_strcasecmp (nmc_fields_dev_show_sections[section_idx]->name, nmc_fields_dev_show_sections[16]->name)) { NMC_OUTPUT_DATA_DEFINE_SCOPED (out); tmpl = (const NMMetaAbstractInfo *const*) nmc_fields_dev_show_bluetooth; @@ -1739,9 +1739,9 @@ do_devices_status (NmCli *nmc, int argc, char **argv) return NMC_RESULT_ERROR_USER_INPUT; } - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = "DEVICE,TYPE,STATE,CONNECTION"; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -3060,9 +3060,9 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) } } - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = NMC_FIELDS_DEV_WIFI_LIST_COMMON; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -4518,9 +4518,9 @@ do_device_lldp_list (NmCli *nmc, int argc, char **argv) next_arg (nmc, &argc, &argv, NULL); } - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = NMC_FIELDS_DEV_LLDP_LIST_COMMON; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) { + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; diff --git a/clients/cli/general.c b/clients/cli/general.c index ccda0d52e3..d806d04897 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -467,9 +467,9 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl const char *fields_all = print_flds ?: NMC_FIELDS_NM_STATUS_ALL; const char *fields_common = print_flds ?: NMC_FIELDS_NM_STATUS_COMMON; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) fields_str = fields_common; - else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0) + else if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "all") == 0) fields_str = fields_all; else fields_str = nmc->required_fields; @@ -544,8 +544,8 @@ print_permissions (void *user_data) return; } - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) { - } else if (strcasecmp (nmc->required_fields, "all") == 0) { + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) { + } else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -694,8 +694,8 @@ show_general_logging (NmCli *nmc) .domains = &domains_cache, }; - if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) { - } else if (strcasecmp (nmc->required_fields, "all") == 0) { + if (!nmc->required_fields || g_ascii_strcasecmp (nmc->required_fields, "common") == 0) { + } else if (g_ascii_strcasecmp (nmc->required_fields, "all") == 0) { } else fields_str = nmc->required_fields; @@ -874,7 +874,7 @@ nmc_switch_show (NmCli *nmc, const char *switch_name, const char *header) g_return_val_if_fail (nmc != NULL, FALSE); g_return_val_if_fail (switch_name != NULL, FALSE); - if (nmc->required_fields && strcasecmp (nmc->required_fields, switch_name) != 0) { + if (nmc->required_fields && g_ascii_strcasecmp (nmc->required_fields, switch_name) != 0) { g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here (allowed field: %s)"), nmc->required_fields, switch_name); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; |