]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Get rid of multiple MIN macros
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Wed, 10 Jan 2024 14:50:27 +0000 (16:50 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 14 Jan 2024 18:13:20 +0000 (20:13 +0200)
There are multiple redundant MIN macro declarations, some of which are
not protecting against side effects. Move it to common.h instead.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/ap/wmm.c
src/crypto/sha256-internal.c
src/crypto/sha512-internal.c
src/tls/libtommath.c
src/utils/common.h
wpa_supplicant/scan.c

index 9ebb01e3d748b6b86a1c516cc80133b255be9201..dad768e7b8e7469ed5b2aab7e03af553b973cbcd 100644 (file)
 #include "ap_drv_ops.h"
 #include "wmm.h"
 
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
 
 static inline u8 wmm_aci_aifsn(int aifsn, int acm, int aci)
 {
index ff1e2ba1686d3014b011aaf577af86a8ac473329..81e6e5e9c2f36fea9ff024a30376437781d9873b 100644 (file)
@@ -76,9 +76,6 @@ static const unsigned long K[64] = {
 #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
 #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
 #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
 
 /* compress 512-bits */
 static int sha256_compress(struct sha256_state *md, unsigned char *buf)
index c0263941c123c3b0358c6c17b693ac59f0fa46e3..8e98a9cf0532f6d99dbc4a181b4f372e83677203 100644 (file)
@@ -97,9 +97,6 @@ static const u64 K[80] = {
 #define Sigma1(x)       (S(x, 14) ^ S(x, 18) ^ S(x, 41))
 #define Gamma0(x)       (S(x, 1) ^ S(x, 8) ^ R(x, 7))
 #define Gamma1(x)       (S(x, 19) ^ S(x, 61) ^ R(x, 6))
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
 
 #define ROR64c(x, y) \
     ( ((((x) & CONST64(0xFFFFFFFFFFFFFFFF)) >> ((u64) (y) & CONST64(63))) | \
index 715674424324d9bad5621e24ebedadffeb0c5c83..ed595bd62d72de786914c742be210829e14fbf10 100644 (file)
 
 /* from tommath.h */
 
-#ifndef MIN
-   #define MIN(x,y) ((x)<(y)?(x):(y))
-#endif
-
-#ifndef MAX
-   #define MAX(x,y) ((x)>(y)?(x):(y))
-#endif
-
 #define  OPT_CAST(x)
 
 #ifdef __x86_64__
index ce17c8011e66c48a0d9cea40b71afc27f6ab65df..d4ffb998bae4826047d651438009d6393f1c427c 100644 (file)
@@ -441,6 +441,13 @@ void perror(const char *s);
 #define BIT(x) (1U << (x))
 #endif
 
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
 /*
  * Definitions for sparse validation
  * (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
index aef85461c8c443695fdc493aeb49935ca8d0e470..6e6f05d423c33202df2266c977412d9712454439 100644 (file)
@@ -2255,7 +2255,6 @@ static int wpas_channel_width_offset(enum chan_width cw)
 static int wpas_channel_width_tx_pwr(const u8 *ies, size_t ies_len,
                                     enum chan_width cw)
 {
-#define MIN(a, b) (a < b ? a : b)
        int offset = wpas_channel_width_offset(cw);
        const struct element *elem;
        int max_tx_power = TX_POWER_NO_CONSTRAINT, tx_pwr = 0;
@@ -2331,7 +2330,6 @@ static int wpas_channel_width_tx_pwr(const u8 *ies, size_t ies_len,
        }
 
        return max_tx_power;
-#undef MIN
 }
 
 
@@ -2373,7 +2371,6 @@ int wpas_adjust_snr_by_chanwidth(const u8 *ies, size_t ies_len,
  * better. */
 static int wpa_scan_result_compar(const void *a, const void *b)
 {
-#define MIN(a,b) a < b ? a : b
        struct wpa_scan_res **_wa = (void *) a;
        struct wpa_scan_res **_wb = (void *) b;
        struct wpa_scan_res *wa = *_wa;
@@ -2477,7 +2474,6 @@ static int wpa_scan_result_compar(const void *a, const void *b)
        if (snr_b_full == snr_a_full)
                return wb->qual - wa->qual;
        return snr_b_full - snr_a_full;
-#undef MIN
 }