]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use bool for is_6ghz variables and functions
authorJouni Malinen <jouni@codeaurora.org>
Fri, 11 Dec 2020 15:18:09 +0000 (17:18 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 11 Dec 2020 17:56:14 +0000 (19:56 +0200)
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>
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h
wpa_supplicant/dpp_supplicant.c
wpa_supplicant/op_classes.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/rrm.c
wpa_supplicant/scan.c
wpa_supplicant/scan.h
wpa_supplicant/sme.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 531def45871d1e4d4429363e521c15973db30d6a..c90e04ce7e3850a6c23f02b2197c617b82224ee8 100644 (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;
 }
 
 
index 473e00cfdd4d131164403d71e1746d694669eb0f..6bbe3b7a3492b6652ffeaba2d78aa1dd96fc054b 100644 (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);
index 74514886ad58d1c899f26d76e55d909ed4323cf7..09355cf7f5d9f9d34e36318b4010dde07b6281e9 100644 (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];
index b4c0c8a0b0d8207f8964863b1bb42f424d5b9702..41b47cc6295cb64c338744a7172c6ad6907d44ee 100644 (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;
index 91ffbf6e2651fd799cefa64d8c94c01851d0546a..867874dd98797fe1b360b3135f1d4099c7b2f442 100644 (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");
index a9c7b90fdc93bc372f9bb80add9a82697d2edcff..242496d0a1cc1e4685660f9ef6592ef080c2eca4 100644 (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
index 5339b796b52793d48fd7e332d475b775906a24cd..5d301630506beea5f7f8faaac0b1c20186740e71 100644 (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;
index 4dd3f8360cbc2ed3328972bfe8933f84a6beb98f..8eb5c73e275e71e0dabbbb5b859fa9adae7f0902 100644 (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 */
index 9b4eeb915150dad0937ca8b2dc3bda833ae775c2..46963e92f96377b22c0e1d5dcfeed570814cd1d5 100644 (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));
index 5560197bdfda8faf709ea85b1f55a547ba9968fa..fc0574e037b1d362ac44909b89a01de0dae2460b 100644 (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;
 
index 212cc37b664097e28c67da0083ed304531c6bae5..568e383b1e352530052bdf728ab731836176866c 100644 (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);