From 9542f21f3a306885fa39a867f5b5382fecdbf1ae Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 28 Feb 2015 21:58:38 +0200 Subject: [PATCH] Clean up p2p_find command parsing and execution There is no need to maintain three almost identical copies of the wpas_p2p_find() call. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index e92d8635e..a2d79face 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -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); }