From: martin.brugnara@gmail.com (Martin Brugnara)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Linux-wireless: why use macro to call functions
Date: Mon, 23 Dec 2013 11:23:07 +0100 [thread overview]
Message-ID: <52b80f05.c7b60e0a.2515.5c5e@mx.google.com> (raw)
Hi,
Why here is used a macro instead of an inline func.
Thanks,
Martin
-----Original Message-----
From: "Daniel Baluta" <daniel.baluta@gmail.com>
Sent: ?23/?12/?2013 08.27
To: "Fred Chou" <fred.chou.nd@gmail.com>
Cc: "kernelnewbies" <kernelnewbies@kernelnewbies.org>
Subject: Re: Linux-wireless: why use macro to call functions
On Mon, Dec 23, 2013 at 8:05 AM, Fred Chou <fred.chou.nd@gmail.com> wrote:
> Hi,
>
> I was studying the Linux wireless subsystem code and noticed this code (in
> ieee80211_rx_handlers):
>
> It first defines the macro:
>
> #define CALL_RXH(rxh) \
> do { \
> res = rxh(rx); \
> if (res != RX_CONTINUE) \
> goto rxh_next; \
> } while (0);
>
> Then the macro is used to call a series of functions:
>
> CALL_RXH(ieee80211_rx_h_check_more_data)
> CALL_RXH(ieee80211_rx_h_uapsd_and_pspoll)
> CALL_RXH(ieee80211_rx_h_sta_process)
> CALL_RXH(ieee80211_rx_h_decrypt)
> CALL_RXH(ieee80211_rx_h_defragment)
> CALL_RXH(ieee80211_rx_h_michael_mic_verify)
>
>
> My question is, why not just call the functions directly like:
>
> ieee80211_rx_h_check_more_data(rx);
> ieee80211_rx_h_uapsd_and_pspoll(rx);
>
> ...
>
> Is it just for the sake of outlining the code for easy reading? Appreciate
> if anyone can explain. Thanks!
Hi,
As you can see above the macro does also error checking.I don't necessarily
think that the code is easier to read, but it can save you some typing.
thanks,
Daniel.
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131223/49f72ac0/attachment.html
next reply other threads:[~2013-12-23 10:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-23 10:23 Martin Brugnara [this message]
2013-12-23 12:03 ` Linux-wireless: why use macro to call functions Bernd Petrovitsch
2013-12-24 12:19 ` Fred Chou
2013-12-24 13:35 ` Greg Freemyer
2013-12-24 13:48 ` Adrian Ratnapala
2013-12-24 16:47 ` Valdis.Kletnieks at vt.edu
-- strict thread matches above, loose matches on Subject: below --
2013-12-23 6:05 Fred Chou
2013-12-23 7:25 ` Daniel Baluta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52b80f05.c7b60e0a.2515.5c5e@mx.google.com \
--to=martin.brugnara@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).