[PATCH] Staging: rtl8712: Remove redundant parentheses and improve macro definition

From: Inshal Khan
Date: Tue Mar 21 2023 - 06:41:48 EST


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@xxxxxxxxx>
---
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