From a8ad9c31db0e5357d19f74000d749eb4dc6b486b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 1 Jan 2020 17:46:03 +0200 Subject: [PATCH] Make min_diff determination from cur_level more readable This handles both the dBm and unspecified unit cases. Signed-off-by: Jouni Malinen --- wpa_supplicant/events.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fe6e9ea61..4daab3f2f 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1817,19 +1817,18 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 0; } - min_diff = 2; - if (cur_level < 0) { - if (cur_level < -85) - min_diff = 1; - else if (cur_level < -80) - min_diff = 2; - else if (cur_level < -75) - min_diff = 3; - else if (cur_level < -70) - min_diff = 4; - else - min_diff = 5; - } + if (cur_level < -85) /* ..-86 dBm */ + min_diff = 1; + else if (cur_level < -80) /* -85..-81 dBm */ + min_diff = 2; + else if (cur_level < -75) /* -80..-76 dBm */ + min_diff = 3; + else if (cur_level < -70) /* -75..-71 dBm */ + min_diff = 4; + else if (cur_level < 0) /* -70..-1 dBm */ + min_diff = 5; + else /* unspecified units (not in dBm) */ + min_diff = 2; if (cur_est > sel_est * 1.5) min_diff += 10;