commit bef550df810cf6e6e3c72c0569cef7b89a423f1a
parent 1fd6aba43cd0b5a2bfe50c5c81c9e3954ade77e1
Author: Denis Kenzior <denkenz@gmail.com>
Date: Wed, 19 Jan 2022 14:20:48 -0600
scan: Simplify scan_finished
There are similar operations being performed but with different
callbacks and userdata, depending on whether 'sr' is NULL or not.
Optimize the function flow slightly to make if-else unnecessary.
While here, update the comment. periodic scans are now scheduled only
based on the periodic timeout timer.
Diffstat:
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/scan.c b/src/scan.c
@@ -1703,32 +1703,32 @@ static void scan_finished(struct scan_context *sc,
struct scan_request *sr)
{
bool new_owner = false;
+ scan_notify_func_t callback = sr ? sr->callback : sc->sp.callback;
+ void *userdata = sr ? sr->userdata : sc->sp.userdata;
if (bss_list)
discover_hidden_network_bsses(sc, bss_list);
- if (sr) {
+ if (sr)
l_queue_remove(sc->requests, sr);
- if (sr->callback)
- new_owner = sr->callback(err, bss_list,
- freqs, sr->userdata);
-
- /*
- * Can start a new scan now that we've removed this one from
- * the queue. If this were an external scan request (sr NULL)
- * then the SCAN_FINISHED or SCAN_ABORTED handler would have
- * taken care of sending the next command for a new or ongoing
- * scan, or scheduling the next periodic scan.
- */
- wiphy_radio_work_done(sc->wiphy, sr->work.id);
- } else if (sc->sp.callback)
- new_owner = sc->sp.callback(err, bss_list,
- freqs, sc->sp.userdata);
+ if (callback)
+ new_owner = callback(err, bss_list, freqs, userdata);
if (bss_list && !new_owner)
l_queue_destroy(bss_list,
(l_queue_destroy_func_t) scan_bss_free);
+
+ if (!sr)
+ return;
+
+ /*
+ * Can start a new scan now that we've removed this one from the
+ * queue. If this were an external scan request (sr NULL) then the
+ * SCAN_FINISHED or SCAN_ABORTED handler would have taken care of
+ * sending the next command for a new or ongoing scan.
+ */
+ wiphy_radio_work_done(sc->wiphy, sr->work.id);
}
static void get_scan_done(void *user)