From patchwork Wed Jan 10 14:50:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1885012 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wgKHtIF4; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Vc8tZTFj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T99kP1kRyz1xqk for ; Thu, 11 Jan 2024 01:52:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=oe/1lQLKseYJq+AKs20Jexp/urnH/O0DbZBF7QY3ARk=; b=wgKHtIF4pBPYQi j0P3YnI13IL0+1Nxclih0hDmp/frGpzVXyPMTfgS/Jm4Z+0tnwTQL0o+ewHuOfKyhpvKI4M3A6umO HK/k6ZUHyYGsbwArB1+DQJJON/4SdvkGRgnEE4MdpqZ82AJjJtcYRScSKQXLHVGDyZ6zBezuGIhy0 QZWow+CFjw+hjAlMrMMlPpmUKYUbieOq5ccmap9WIaTm3UMe2ueq61BDeguleDQ3FbC5x91RpshZJ NMl3l+2nJhpV4BfPsWFWewiqhstEwKGEB13zohqrysqQNmPGQtv7lf2FBgD3EEJO8uUK9E6ciM7JQ RIcGwvgIjhoMapqgNeqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNZvP-00CPa2-1D; Wed, 10 Jan 2024 14:51:23 +0000 Received: from mgamail.intel.com ([192.198.163.7]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNZvM-00CPYo-0r for hostap@lists.infradead.org; Wed, 10 Jan 2024 14:51:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704898280; x=1736434280; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2WOeBJmg8KYcz8LuhMkUdbXOeG5WSQBgKEeULYMMkfY=; b=Vc8tZTFjP1S4RlBWKc2vA9xSFbUZagvUHySVwaFlo9BleNb3fFu6B+hb ixyDtSKJP2OmAW1RSrbkfKfzTkfKpnabV1zjjPt9zwpXmReiMLSaxnZM7 AhE74mvF7YQMGO8Siqfw7rmcurmNuNbiWxcGs3LtlTDNfplCuF1hUol+z Z+4S2h1OzEV2sgiXQDalbFVT6yXJoVQyhbAaTkMyRKIrX/RFOgIVwpZjw jFn9Gw9k7YX8aRELKc4vAFH3mQpnJe0BZukX9Zav0A3gF59bvwOYRlMVp d91GTrTTf4QC4JuEhWVKNa/zmp5BAVAIHIjemN5F+PaBEwKr5EVTALCF6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10948"; a="20031395" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="20031395" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 06:51:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10948"; a="955396538" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="955396538" Received: from unknown (HELO WEIS0042.iil.intel.com) ([10.12.217.211]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 06:51:18 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: Andrei Otcheretianski Subject: [PATCH] Get rid of multiple MIN macros Date: Wed, 10 Jan 2024 16:50:27 +0200 Message-ID: <20240110145028.2496937-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240110_065120_349779_C4997EC9 X-CRM114-Status: GOOD ( 12.21 ) X-Spam-Score: -0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: There are multiple redundant MIN macro declarations, some of which are even wrong. Move it to common.h instead. Signed-off-by: Andrei Otcheretianski --- src/ap/wmm.c | 7 ------- src/crypto/sha256-internal.c | 3 --- src/crypto/sha512-internal.c | 3 --- src/utils/common.h | 7 +++ [...] Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org There are multiple redundant MIN macro declarations, some of which are even wrong. Move it to common.h instead. Signed-off-by: Andrei Otcheretianski --- src/ap/wmm.c | 7 ------- src/crypto/sha256-internal.c | 3 --- src/crypto/sha512-internal.c | 3 --- src/utils/common.h | 7 +++++++ wpa_supplicant/scan.c | 4 ---- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/ap/wmm.c b/src/ap/wmm.c index 9ebb01e3d7..dad768e7b8 100644 --- a/src/ap/wmm.c +++ b/src/ap/wmm.c @@ -20,13 +20,6 @@ #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) { diff --git a/src/crypto/sha256-internal.c b/src/crypto/sha256-internal.c index ff1e2ba168..81e6e5e9c2 100644 --- a/src/crypto/sha256-internal.c +++ b/src/crypto/sha256-internal.c @@ -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) diff --git a/src/crypto/sha512-internal.c b/src/crypto/sha512-internal.c index c0263941c1..8e98a9cf05 100644 --- a/src/crypto/sha512-internal.c +++ b/src/crypto/sha512-internal.c @@ -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))) | \ diff --git a/src/utils/common.h b/src/utils/common.h index bede21e571..a9f3e44caa 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -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/) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 6e03a13ce6..d074672afe 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -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 }