]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Clean up p2p_find command parsing and execution
authorJouni Malinen <j@w1.fi>
Sat, 28 Feb 2015 19:58:38 +0000 (21:58 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 28 Feb 2015 19:58:38 +0000 (21:58 +0200)
There is no need to maintain three almost identical copies of the
wpas_p2p_find() call.

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

index e92d8635e32099ae66a5a0d1ef197c3821073a2a..a2d79faceecb8c2a220c67219ca284d2adb93432 100644 (file)
@@ -4508,7 +4508,7 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
        u8 dev_type[WPS_DEV_TYPE_LEN], *_dev_type = NULL;
        char *pos;
        unsigned int search_delay;
-       const char *seek[P2P_MAX_QUERY_HASH + 1];
+       const char *_seek[P2P_MAX_QUERY_HASH + 1], **seek = NULL;
        u8 seek_count = 0;
        int freq = 0;
 
@@ -4551,12 +4551,17 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
                char *term;
 
                term = os_strchr(pos + 1, ' ');
-               seek[seek_count++] = pos + 6;
+               _seek[seek_count++] = pos + 6;
+               seek = _seek;
                pos = os_strstr(pos + 6, " seek=");
 
                if (term)
                        *term = '\0';
        }
+       if (seek_count > P2P_MAX_QUERY_HASH) {
+               seek[0] = NULL;
+               seek_count = 1;
+       }
 
        pos = os_strstr(cmd, "freq=");
        if (pos) {
@@ -4566,18 +4571,6 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
                        return -1;
        }
 
-       if (!seek_count)
-               return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
-                                    _dev_type, _dev_id,
-                                    search_delay, 0, NULL, freq);
-
-       if (seek_count > P2P_MAX_QUERY_HASH) {
-               seek[0] = NULL;
-               return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL,
-                                    _dev_type, _dev_id,
-                                    search_delay, 1, seek, freq);
-       }
-
        return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
                             _dev_id, search_delay, seek_count, seek, freq);
 }