[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBmJ0luUeoX/uhZp@mehmed-HP-Pavilion-Laptop-15-eh2xxx>
Date: Tue, 21 Mar 2023 16:11:22 +0530
From: Inshal Khan <kziaul123@...il.com>
To: gregkh@...uxfoundation.org
Cc: linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: [PATCH] Staging: rtl8712: Remove redundant parentheses and improve
macro definition
This commit simplifies the code in the ieee80211 and osdep_intf modules by
removing unnecessary parentheses and improving the readability and avoiding
any unexpected as well as operator preceedence side effects of RND4 macro.
These changes improve the robustness of the driver and make it easier to
maintain going forward.
Signed-off-by: Inshal Khan <kziaul123@...il.com>
---
drivers/staging/rtl8712/ieee80211.c | 10 +++++-----
drivers/staging/rtl8712/osdep_intf.h | 5 ++++-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
index 7d8f1a29d18a..85e698c2126d 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -63,8 +63,8 @@ uint r8712_is_cckrates_included(u8 *rate)
u32 i = 0;
while (rate[i] != 0) {
- if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
- (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
+ if (((rate[i] & 0x7f) == 2) || ((rate[i] & 0x7f) == 4) ||
+ ((rate[i] & 0x7f) == 11) || ((rate[i] & 0x7f) == 22))
return true;
i++;
}
@@ -76,8 +76,8 @@ uint r8712_is_cckratesonly_included(u8 *rate)
u32 i = 0;
while (rate[i] != 0) {
- if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
- (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
+ if (((rate[i] & 0x7f) != 2) && ((rate[i] & 0x7f) != 4) &&
+ ((rate[i] & 0x7f) != 11) && ((rate[i] & 0x7f) != 22))
return false;
i++;
}
@@ -147,7 +147,7 @@ static uint r8712_get_rateset_len(u8 *rateset)
uint i = 0;
while (1) {
- if ((rateset[i]) == 0)
+ if (rateset[i] == 0)
break;
if (i > 12)
break;
diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h
index 9e75116c987e..3d4f82cc60f9 100644
--- a/drivers/staging/rtl8712/osdep_intf.h
+++ b/drivers/staging/rtl8712/osdep_intf.h
@@ -17,7 +17,10 @@
#include "osdep_service.h"
#include "drv_types.h"
-#define RND4(x) (((x >> 2) + ((x & 3) != 0)) << 2)
+#define RND4(x) ({ \
+ typeof(x) _x = (x); \
+ (((_x) + 3) & ~3); \
+ })
struct intf_priv {
u8 *intf_dev;
--
2.34.1
Powered by blists - more mailing lists