Skip to contentSkip to conversation

Staging: rtl8712 : osdep_intf.h: fix macro coding style issue

PATCH In review Jaya Durga 2 participants 2 messages Jun 27, 2017 Staging

lore
Share & tools
lore

Jaya Durga

author
#0 lore raw

PATCH 4/4 Staging: rtl8712 : osdep_intf.h: fix macro coding style issue

Fix checkpatch.pl warning of the form "CHECK" Macro argument 'x' may be better as '(x)' to avoid precedence issues.

---
 drivers/staging/rtl8712/osdep_intf.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/rtl8712/osdep_intf.h +4 -1
index 1985423..dac6aed 100644
@@ -29,7 +29,10 @@
 #include "osdep_service.h"
 #include "drv_types.h"
 
-#define RND4(x)	((((x) >> 2) + ((((x) & 3) == 0) ?  0 : 1)) << 2)
+static inline unsigned int RND4(unsigned int x)
+{
+	return (((x >> 2) + (((x & 3) == 0) ?  0 : 1)) << 2);
+}
 
 struct intf_priv {
 	u8 *intf_dev;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 13 lines · Jaya Durga

Fix checkpatch.pl warning of the form "CHECK" Macro argument 'x' may be better as '(x)' to avoid precedence issues.

---
 drivers/staging/rtl8712/osdep_intf.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/rtl8712/osdep_intf.h +0 -0
index 1985423..dac6aed 100644

drivers/staging/rtl8712/osdep_intf.h line 35

Quoted 8 lines
drivers/staging/rtl8712/osdep_intf.h +4 -1
@@ -29,7 +29,10 @@
 #include "osdep_service.h"
 #include "drv_types.h"
 
-#define RND4(x)        ((((x) >> 2) + ((((x) & 3) == 0) ?  0 : 1)) << 2)
+static inline unsigned int RND4(unsigned int x)
+{
+       return (((x >> 2) + (((x & 3) == 0) ?  0 : 1)) << 2);
+}

Looks like the checkpatch warning has already been addressed, or checkpatch throws a false positive there.

I like this inline function better than the macro, since

RND(get_some_value());

may return funky results.

Frans