ifcfg: make Coverity happy
authorLubomir Rintel <lkundrak@v3.sk>
Fri, 29 Jan 2016 08:45:35 +0000 (09:45 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Fri, 29 Jan 2016 19:18:21 +0000 (20:18 +0100)
CID 59382 (#1 of 1): Dereference null return value (NULL_RETURNS)
10.  dereference: Dereferencing a pointer that might be null value
when calling strcmp.

Not exactly true, since we ruled out the posibility earlier; but
we could still get rid of a couple of strcmps.

src/settings/plugins/ifcfg-rh/reader.c

index 6f20dc1..d03fafe 100644 (file)
@@ -3148,8 +3148,7 @@ make_wpa_setting (shvarFile *ifcfg,
                g_free (allow_rsn);
        }
 
-       /* coverity[dereference] */
-       if (!strcmp (value, "WPA-PSK")) {
+       if (wpa_psk) {
                NMSettingSecretFlags psk_flags;
 
                psk_flags = read_secret_flags (ifcfg, "WPA_PSK_FLAGS");
@@ -3169,7 +3168,7 @@ make_wpa_setting (shvarFile *ifcfg,
                        g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL);
                else
                        g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
-       } else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) {
+       } else if (wpa_eap || ieee8021x) {
                /* Adhoc mode is mutually exclusive with any 802.1x-based authentication */
                if (adhoc) {
                        g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,