Skip to contentSkip to conversation

Staging: rts5208: Fix Macro argument reuse

PATCH Superseded Bhanusree Pola 2 participants 2 messages Feb 19, 2019 – Feb 20, 2019 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Staging: rts5208: Fix Macro argument reuse

Fix Macro argument reuse to avoid possible side effects

---
 drivers/staging/rts5208/xd.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/rts5208/xd.h +5 -4
index 98c00f268e56..5e9b3805c33a 100644
@@ -99,11 +99,12 @@
 #define	XD_RW_ADDR			0x01
 #define	XD_ERASE_ADDR			0x02
 
-#define	XD_PAGE_512(xd_card)		\
+#define	XD_PAGE_512(_card)		\
+(typeof(_card) (card) = (_card);	\
 do {					\
-	(xd_card)->block_shift = 5;	\
-	(xd_card)->page_off = 0x1F;	\
-} while (0)
+	(card)->block_shift = 5;	\
+	(card)->page_off = 0x1F;	\
+} while (0))
 
 #define	XD_SET_BAD_NEWBLK(xd_card)	((xd_card)->multi_flag |= 0x01)
 #define	XD_CLR_BAD_NEWBLK(xd_card)	((xd_card)->multi_flag &= ~0x01)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 1 line · Bhanusree Pola

Fix Macro argument reuse to avoid possible side effects

What side effects? Always be specific.

And if you do something like this, make it an inline function, that way the type can be properly checked.

thanks,

greg k-h