Use bool for is_6ghz variables and functions

Replace the implicit boolean checks that used int variables with use of
a more explicit bool variable type.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-12-11 17:18:09 +02:00 committed by Jouni Malinen
parent 9a411882bd
commit 6ead8b897f
11 changed files with 28 additions and 27 deletions

View file

@ -2245,44 +2245,44 @@ int center_idx_to_bw_6ghz(u8 idx)
}
int is_6ghz_freq(int freq)
bool is_6ghz_freq(int freq)
{
if (freq < 5935 || freq > 7115)
return 0;
return false;
if (freq == 5935)
return 1;
return true;
if (center_idx_to_bw_6ghz((freq - 5950) / 5) < 0)
return 0;
return false;
return 1;
return true;
}
int is_6ghz_op_class(u8 op_class)
bool is_6ghz_op_class(u8 op_class)
{
return op_class >= 131 && op_class <= 136;
}
int is_6ghz_psc_frequency(int freq)
bool is_6ghz_psc_frequency(int freq)
{
int i;
if (!is_6ghz_freq(freq) || freq == 5935)
return 0;
return false;
if ((((freq - 5950) / 5) & 0x3) != 0x1)
return 0;
return false;
i = (freq - 5950 + 55) % 80;
if (i == 0)
i = (freq - 5950 + 55) / 80;
if (i >= 1 && i <= 15)
return 1;
return true;
return 0;
return false;
}

View file

@ -259,9 +259,9 @@ u8 country_to_global_op_class(const char *country, u8 op_class);
const struct oper_class_map * get_oper_class(const char *country, u8 op_class);
int oper_class_bw_to_int(const struct oper_class_map *map);
int center_idx_to_bw_6ghz(u8 idx);
int is_6ghz_freq(int freq);
int is_6ghz_op_class(u8 op_class);
int is_6ghz_psc_frequency(int freq);
bool is_6ghz_freq(int freq);
bool is_6ghz_op_class(u8 op_class);
bool is_6ghz_psc_frequency(int freq);
int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
size_t nei_rep_len);

View file

@ -3493,7 +3493,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
/* Preferred chirping channels */
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
HOSTAPD_MODE_IEEE80211G, 0);
HOSTAPD_MODE_IEEE80211G, false);
chan6 = mode == NULL;
if (mode) {
for (c = 0; c < mode->num_channels; c++) {
@ -3510,7 +3510,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
int_array_add_unique(&wpa_s->dpp_chirp_freqs, 2437);
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
HOSTAPD_MODE_IEEE80211A, 0);
HOSTAPD_MODE_IEEE80211A, false);
if (mode) {
int chan44 = 0, chan149 = 0;
@ -3532,7 +3532,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s,
}
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
HOSTAPD_MODE_IEEE80211AD, 0);
HOSTAPD_MODE_IEEE80211AD, false);
if (mode) {
for (c = 0; c < mode->num_channels; c++) {
struct hostapd_channel_data *chan = &mode->channels[c];

View file

@ -22,10 +22,10 @@ static enum chan_allowed allow_channel(struct hostapd_hw_modes *mode,
unsigned int *flags)
{
int i;
int is_6ghz = op_class >= 131 && op_class <= 136;
bool is_6ghz = op_class >= 131 && op_class <= 136;
for (i = 0; i < mode->num_channels; i++) {
int chan_is_6ghz;
bool chan_is_6ghz;
chan_is_6ghz = mode->channels[i].freq >= 5935 &&
mode->channels[i].freq <= 7115;

View file

@ -1921,7 +1921,7 @@ static int wpas_p2p_freq_to_edmg_channel(struct wpa_supplicant *wpa_s,
return -1;
hwmode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
HOSTAPD_MODE_IEEE80211AD, 0);
HOSTAPD_MODE_IEEE80211AD, false);
if (!hwmode) {
wpa_printf(MSG_ERROR,
"Unsupported AP mode: HOSTAPD_MODE_IEEE80211AD");

View file

@ -563,7 +563,7 @@ static int * wpas_op_class_freqs(const struct oper_class_map *op,
u8 channels_160mhz_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 };
const u8 *channels = NULL;
size_t num_chan = 0;
int is_6ghz = is_6ghz_op_class(op->op_class);
bool is_6ghz = is_6ghz_op_class(op->op_class);
/*
* When adding all channels in the operating class, 80 + 80 MHz

View file

@ -672,7 +672,7 @@ static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s)
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
enum hostapd_hw_mode band,
struct wpa_driver_scan_params *params, int is_6ghz)
struct wpa_driver_scan_params *params, bool is_6ghz)
{
/* Include only supported channels for the specified band */
struct hostapd_hw_modes *mode;

View file

@ -88,6 +88,7 @@ unsigned int wpas_get_est_tpt(const struct wpa_supplicant *wpa_s,
void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
enum hostapd_hw_mode band,
struct wpa_driver_scan_params *params, int is_6ghz);
struct wpa_driver_scan_params *params,
bool is_6ghz);
#endif /* SCAN_H */

View file

@ -2462,7 +2462,7 @@ static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s,
int start, end;
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
HOSTAPD_MODE_IEEE80211G, 0);
HOSTAPD_MODE_IEEE80211G, false);
if (mode == NULL) {
/* No channels supported in this band - use empty list */
params->freqs = os_zalloc(sizeof(int));

View file

@ -3395,7 +3395,7 @@ get_supported_edmg(struct wpa_supplicant *wpa_s,
if (hw_mode == NUM_HOSTAPD_MODES)
goto fail;
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, hw_mode, 0);
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, hw_mode, false);
if (!mode)
goto fail;
@ -8055,7 +8055,7 @@ int wpas_vendor_elem_remove(struct wpa_supplicant *wpa_s, int frame,
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
u16 num_modes, enum hostapd_hw_mode mode,
int is_6ghz)
bool is_6ghz)
{
u16 i;

View file

@ -1620,7 +1620,7 @@ int wpas_sched_scan_plans_set(struct wpa_supplicant *wpa_s, const char *cmd);
struct hostapd_hw_modes * get_mode(struct hostapd_hw_modes *modes,
u16 num_modes, enum hostapd_hw_mode mode,
int is_6ghz);
bool is_6ghz);
void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
unsigned int sec, int rssi_threshold);