ACS: Simplify code paths
This removes some unnecessarily duplicated return paths and simplifies code paths. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
9960434dcf
commit
29be2c090e
1 changed files with 13 additions and 31 deletions
40
src/ap/acs.c
40
src/ap/acs.c
|
@ -331,10 +331,8 @@ acs_survey_chan_interference_factor(struct hostapd_iface *iface,
|
|||
long double int_factor = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
if (dl_list_empty(&chan->survey_list))
|
||||
return;
|
||||
|
||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
||||
if (dl_list_empty(&chan->survey_list) ||
|
||||
(chan->flag & HOSTAPD_CHAN_DISABLED))
|
||||
return;
|
||||
|
||||
chan->interference_factor = 0;
|
||||
|
@ -359,8 +357,7 @@ acs_survey_chan_interference_factor(struct hostapd_iface *iface,
|
|||
(unsigned long) survey->channel_time_rx);
|
||||
}
|
||||
|
||||
if (!count)
|
||||
return;
|
||||
if (count)
|
||||
chan->interference_factor /= count;
|
||||
}
|
||||
|
||||
|
@ -450,12 +447,8 @@ static int acs_surveys_are_sufficient(struct hostapd_iface *iface)
|
|||
|
||||
for (i = 0; i < iface->current_mode->num_channels; i++) {
|
||||
chan = &iface->current_mode->channels[i];
|
||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
||||
continue;
|
||||
|
||||
if (!acs_survey_list_is_sufficient(chan))
|
||||
continue;
|
||||
|
||||
if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
|
||||
acs_survey_list_is_sufficient(chan))
|
||||
valid++;
|
||||
}
|
||||
|
||||
|
@ -466,13 +459,9 @@ static int acs_surveys_are_sufficient(struct hostapd_iface *iface)
|
|||
|
||||
static int acs_usable_chan(struct hostapd_channel_data *chan)
|
||||
{
|
||||
if (dl_list_empty(&chan->survey_list))
|
||||
return 0;
|
||||
if (chan->flag & HOSTAPD_CHAN_DISABLED)
|
||||
return 0;
|
||||
if (!acs_survey_list_is_sufficient(chan))
|
||||
return 0;
|
||||
return 1;
|
||||
return !dl_list_empty(&chan->survey_list) &&
|
||||
!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
|
||||
acs_survey_list_is_sufficient(chan);
|
||||
}
|
||||
|
||||
|
||||
|
@ -788,10 +777,7 @@ static int acs_study_survey_based(struct hostapd_iface *iface)
|
|||
|
||||
static int acs_study_options(struct hostapd_iface *iface)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = acs_study_survey_based(iface);
|
||||
if (err == 0)
|
||||
if (acs_study_survey_based(iface) == 0)
|
||||
return 0;
|
||||
|
||||
/* TODO: If no surveys are available/sufficient this is a good
|
||||
|
@ -920,14 +906,11 @@ static int acs_request_scan(struct hostapd_iface *iface)
|
|||
|
||||
enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
|
||||
{
|
||||
int err;
|
||||
|
||||
wpa_printf(MSG_INFO, "ACS: Automatic channel selection started, this may take a bit");
|
||||
|
||||
if (iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) {
|
||||
wpa_printf(MSG_INFO, "ACS: Offloading to driver");
|
||||
err = hostapd_drv_do_acs(iface->bss[0]);
|
||||
if (err)
|
||||
if (hostapd_drv_do_acs(iface->bss[0]))
|
||||
return HOSTAPD_CHAN_INVALID;
|
||||
return HOSTAPD_CHAN_ACS;
|
||||
}
|
||||
|
@ -937,8 +920,7 @@ enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
|
|||
|
||||
acs_cleanup(iface);
|
||||
|
||||
err = acs_request_scan(iface);
|
||||
if (err < 0)
|
||||
if (acs_request_scan(iface) < 0)
|
||||
return HOSTAPD_CHAN_INVALID;
|
||||
|
||||
hostapd_set_state(iface, HAPD_IFACE_ACS);
|
||||
|
|
Loading…
Reference in a new issue