linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: make CALL_TXH a statement
@ 2009-10-29  7:43 Johannes Berg
  2009-10-30 19:11 ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2009-10-29  7:43 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

The multi-line code in this macro wasn't wrapped
in do {} while (0) so we cannot use it in an if()
branch safely in the future -- fix that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/mac80211/tx.c |   34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

--- wireless-testing.orig/net/mac80211/tx.c	2009-10-06 14:57:11.000000000 +0200
+++ wireless-testing/net/mac80211/tx.c	2009-10-06 14:57:39.000000000 +0200
@@ -1201,23 +1201,25 @@ static int invoke_tx_handlers(struct iee
 	struct sk_buff *skb = tx->skb;
 	ieee80211_tx_result res = TX_DROP;
 
-#define CALL_TXH(txh)		\
-	res = txh(tx);		\
-	if (res != TX_CONTINUE)	\
-		goto txh_done;
-
-	CALL_TXH(ieee80211_tx_h_check_assoc)
-	CALL_TXH(ieee80211_tx_h_ps_buf)
-	CALL_TXH(ieee80211_tx_h_select_key)
-	CALL_TXH(ieee80211_tx_h_michael_mic_add)
-	CALL_TXH(ieee80211_tx_h_rate_ctrl)
-	CALL_TXH(ieee80211_tx_h_misc)
-	CALL_TXH(ieee80211_tx_h_sequence)
-	CALL_TXH(ieee80211_tx_h_fragment)
+#define CALL_TXH(txh) \
+	do {				\
+		res = txh(tx);		\
+		if (res != TX_CONTINUE)	\
+			goto txh_done;	\
+	} while (0)
+
+	CALL_TXH(ieee80211_tx_h_check_assoc);
+	CALL_TXH(ieee80211_tx_h_ps_buf);
+	CALL_TXH(ieee80211_tx_h_select_key);
+	CALL_TXH(ieee80211_tx_h_michael_mic_add);
+	CALL_TXH(ieee80211_tx_h_rate_ctrl);
+	CALL_TXH(ieee80211_tx_h_misc);
+	CALL_TXH(ieee80211_tx_h_sequence);
+	CALL_TXH(ieee80211_tx_h_fragment);
 	/* handlers after fragment must be aware of tx info fragmentation! */
-	CALL_TXH(ieee80211_tx_h_stats)
-	CALL_TXH(ieee80211_tx_h_encrypt)
-	CALL_TXH(ieee80211_tx_h_calculate_duration)
+	CALL_TXH(ieee80211_tx_h_stats);
+	CALL_TXH(ieee80211_tx_h_encrypt);
+	CALL_TXH(ieee80211_tx_h_calculate_duration);
 #undef CALL_TXH
 
  txh_done:



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

* Re: [PATCH] mac80211: make CALL_TXH a statement
  2009-10-29  7:43 [PATCH] mac80211: make CALL_TXH a statement Johannes Berg
@ 2009-10-30 19:11 ` John W. Linville
  2009-10-30 20:43   ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: John W. Linville @ 2009-10-30 19:11 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Thu, Oct 29, 2009 at 08:43:48AM +0100, Johannes Berg wrote:
> The multi-line code in this macro wasn't wrapped
> in do {} while (0) so we cannot use it in an if()
> branch safely in the future -- fix that.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

do {...} while (0) won't work for that either, right?  You need
({...}) instead if you want to return a value.  Is that what you want?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [PATCH] mac80211: make CALL_TXH a statement
  2009-10-30 19:11 ` John W. Linville
@ 2009-10-30 20:43   ` Johannes Berg
  2009-10-30 20:45     ` John W. Linville
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2009-10-30 20:43 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

On Fri, 2009-10-30 at 15:11 -0400, John W. Linville wrote:
> On Thu, Oct 29, 2009 at 08:43:48AM +0100, Johannes Berg wrote:
> > The multi-line code in this macro wasn't wrapped
> > in do {} while (0) so we cannot use it in an if()
> > branch safely in the future -- fix that.
> > 
> > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> 
> do {...} while (0) won't work for that either, right?  You need
> ({...}) instead if you want to return a value.  Is that what you want?

No, I just want to be able to do

if (...)
	CALL_TXH(...)

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH] mac80211: make CALL_TXH a statement
  2009-10-30 20:43   ` Johannes Berg
@ 2009-10-30 20:45     ` John W. Linville
  0 siblings, 0 replies; 4+ messages in thread
From: John W. Linville @ 2009-10-30 20:45 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Fri, Oct 30, 2009 at 09:43:47PM +0100, Johannes Berg wrote:
> On Fri, 2009-10-30 at 15:11 -0400, John W. Linville wrote:
> > On Thu, Oct 29, 2009 at 08:43:48AM +0100, Johannes Berg wrote:
> > > The multi-line code in this macro wasn't wrapped
> > > in do {} while (0) so we cannot use it in an if()
> > > branch safely in the future -- fix that.
> > > 
> > > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> > 
> > do {...} while (0) won't work for that either, right?  You need
> > ({...}) instead if you want to return a value.  Is that what you want?
> 
> No, I just want to be able to do
> 
> if (...)
> 	CALL_TXH(...)

Oh, I see -- I misunderstood you.

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

end of thread, other threads:[~2009-10-30 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-29  7:43 [PATCH] mac80211: make CALL_TXH a statement Johannes Berg
2009-10-30 19:11 ` John W. Linville
2009-10-30 20:43   ` Johannes Berg
2009-10-30 20:45     ` John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).