]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Remove unnecessary tracking of first entry
authorJouni Malinen <j@w1.fi>
Sun, 29 Jun 2014 21:50:40 +0000 (00:50 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 2 Jul 2014 09:38:48 +0000 (12:38 +0300)
The pointer to the current position is enough to figure out whether the
proto string is the first one in the buffer. Removing the separate
tracking variable cleans up a static analyzer warning on dead
assignment.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/config.c

index 86d6d7213de9104289c055a7c51a403152eb86b2..16031c9237e25956c676caec7b7bcad7305cd5ef 100644 (file)
@@ -435,7 +435,7 @@ static int wpa_config_parse_proto(const struct parse_data *data,
 static char * wpa_config_write_proto(const struct parse_data *data,
                                     struct wpa_ssid *ssid)
 {
-       int first = 1, ret;
+       int ret;
        char *buf, *pos, *end;
 
        pos = buf = os_zalloc(20);
@@ -444,27 +444,27 @@ static char * wpa_config_write_proto(const struct parse_data *data,
        end = buf + 20;
 
        if (ssid->proto & WPA_PROTO_WPA) {
-               ret = os_snprintf(pos, end - pos, "%sWPA", first ? "" : " ");
+               ret = os_snprintf(pos, end - pos, "%sWPA",
+                                 pos == buf ? "" : " ");
                if (ret < 0 || ret >= end - pos)
                        return buf;
                pos += ret;
-               first = 0;
        }
 
        if (ssid->proto & WPA_PROTO_RSN) {
-               ret = os_snprintf(pos, end - pos, "%sRSN", first ? "" : " ");
+               ret = os_snprintf(pos, end - pos, "%sRSN",
+                                 pos == buf ? "" : " ");
                if (ret < 0 || ret >= end - pos)
                        return buf;
                pos += ret;
-               first = 0;
        }
 
        if (ssid->proto & WPA_PROTO_OSEN) {
-               ret = os_snprintf(pos, end - pos, "%sOSEN", first ? "" : " ");
+               ret = os_snprintf(pos, end - pos, "%sOSEN",
+                                 pos == buf ? "" : " ");
                if (ret < 0 || ret >= end - pos)
                        return buf;
                pos += ret;
-               first = 0;
        }
 
        return buf;