Message ID | 20220317121834.520545-1-bgasmi@freebox.fr |
---|---|
State | Changes Requested |
Headers | show |
Series | Fix MIN() macro | expand |
On Thu, Mar 17, 2022 at 01:18:34PM +0100, Baligh Gasmi wrote:
> Fix macro and avoid macro definition within function.
Can you please be more specific on what is broken and needs to be fixed
here? Why should we avoid defining a macro within a function?
Sorry for that. There is nothing broken, It is just about using a more common style. First, define MIN() macro as defined in other files (wmm.c), and make it available for all the file instead of #define it, and then #undef it. Second, add missing brackets around arguments. Le mer. 6 avr. 2022 à 22:27, Jouni Malinen <j@w1.fi> a écrit : > > On Thu, Mar 17, 2022 at 01:18:34PM +0100, Baligh Gasmi wrote: > > Fix macro and avoid macro definition within function. > > Can you please be more specific on what is broken and needs to be fixed > here? Why should we avoid defining a macro within a function? > > -- > Jouni Malinen PGP id EFC895FA
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index b0094ca6c..4265f25ee 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -24,6 +24,9 @@ #include "scan.h" #include "mesh.h" +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s) { @@ -2046,12 +2049,10 @@ struct wpabuf * wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res *res, return buf; } - /* Compare function for sorting scan results. Return >0 if @b is considered * 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; @@ -2116,7 +2117,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 }
Fix macro and avoid macro definition within function. Signed-off-by: Baligh Gasmi <bgasmi@freebox.fr> --- wpa_supplicant/scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)