All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] Staging: ks7010: hostif: Fix multiple use of arguments in SME queue macros.
@ 2018-02-17  2:25 Quytelda Kahja
  2018-02-17  2:25 ` [PATCH 3/4] Staging: ks7010: hostif: Fix multiple use of arguments in rate and event masking macros Quytelda Kahja
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Quytelda Kahja @ 2018-02-17  2:25 UTC (permalink / raw)
  To: gregkh, wsa; +Cc: devel, driverdev-devel, linux-kernel, Quytelda Kahja

Use GCC extensions to prevent macro arguments from accidentally being evaluated
multiple times when the macro is called.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/ks7010/ks_hostif.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 975dbbb3abd0..30c9592b3a00 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -22,12 +22,19 @@
 #include <net/iw_handler.h>	/* New driver API */
 
 /* macro */
-#define inc_smeqhead(priv) \
-	(priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE)
-#define inc_smeqtail(priv) \
-	(priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE)
-#define cnt_smeqbody(priv) \
-	(((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE)
+#define inc_smeqhead(priv)						\
+	({ typeof(priv) priv_ = (priv);					\
+		unsigned int next_qhead = priv_->sme_i.qhead + 1;	\
+		priv_->sme_i.qhead = next_qhead % SME_EVENT_BUFF_SIZE; })
+#define inc_smeqtail(priv)						\
+	({ typeof(priv) priv_ = (priv);					\
+		unsigned int next_qtail = priv_->sme_i.qtail + 1;	\
+		priv_->sme_i.qtail = next_qtail % SME_EVENT_BUFF_SIZE; })
+#define cnt_smeqbody(priv)						\
+	({ typeof(priv) priv_ = (priv);					\
+		unsigned int left_cnt =					\
+			priv_->sme_i.qtail + SME_EVENT_BUFF_SIZE;	\
+		 (left_cnt - (priv_->sme_i.qhead)) % SME_EVENT_BUFF_SIZE; })
 
 #define KS_WLAN_MEM_FLAG (GFP_ATOMIC)
 
-- 
2.16.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-02-20  6:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-17  2:25 [PATCH 2/4] Staging: ks7010: hostif: Fix multiple use of arguments in SME queue macros Quytelda Kahja
2018-02-17  2:25 ` [PATCH 3/4] Staging: ks7010: hostif: Fix multiple use of arguments in rate and event masking macros Quytelda Kahja
2018-02-19 17:12   ` Greg KH
2018-02-17  2:25 ` [PATCH 4/4] Staging: ks7010: hostif: Fix multiple use of arguments in ps_confirm_wait_inc() macro Quytelda Kahja
2018-02-19 17:08 ` [PATCH 2/4] Staging: ks7010: hostif: Fix multiple use of arguments in SME queue macros Greg KH
2018-02-20  6:35   ` [PATCH v2 1/3] Staging: ks7010: sdio: Convert RX/TX queue macros into real functions Quytelda Kahja
2018-02-20  6:35     ` [PATCH v2 2/3] Staging: ks7010: hostif: Convert SME queue macros to " Quytelda Kahja
2018-02-20  6:35     ` [PATCH v2 3/3] Staging: ks7010: hostif: Convert the ps_confirm_wait_inc() macro to a real function Quytelda Kahja

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.