<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type></HEAD>
<BODY>
<DIV>
<DIV style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif">Hi,<BR><BR>Why here is used a macro instead of an inline func.<BR><BR>Thanks,<BR>Martin</DIV></DIV>
<DIV dir=ltr>
<HR>
<SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif; FONT-WEIGHT: bold">From: </SPAN><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif"><A href="mailto:daniel.baluta@gmail.com">Daniel Baluta</A></SPAN><BR><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif; FONT-WEIGHT: bold">Sent: </SPAN><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif">23/12/2013 08.27</SPAN><BR><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif; FONT-WEIGHT: bold">To: </SPAN><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif"><A href="mailto:fred.chou.nd@gmail.com">Fred Chou</A></SPAN><BR><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif; FONT-WEIGHT: bold">Cc: </SPAN><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif"><A href="mailto:kernelnewbies@kernelnewbies.org">kernelnewbies</A></SPAN><BR><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif; FONT-WEIGHT: bold">Subject: </SPAN><SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri,sans-serif">Re: Linux-wireless: why use macro to call functions</SPAN><BR><BR></DIV>On Mon, Dec 23, 2013 at 8:05 AM, Fred Chou <fred.chou.nd@gmail.com> wrote:<BR>> Hi,<BR>><BR>> I was studying the Linux wireless subsystem code and noticed this code (in<BR>> ieee80211_rx_handlers):<BR>><BR>> It first defines the macro:<BR>><BR>> #define CALL_RXH(rxh) \<BR>> do { \<BR>> res = rxh(rx); \<BR>> if (res != RX_CONTINUE) \<BR>> goto rxh_next; \<BR>> } while (0);<BR>><BR>> Then the macro is used to call a series of functions:<BR>><BR>> CALL_RXH(ieee80211_rx_h_check_more_data)<BR>> CALL_RXH(ieee80211_rx_h_uapsd_and_pspoll)<BR>> CALL_RXH(ieee80211_rx_h_sta_process)<BR>> CALL_RXH(ieee80211_rx_h_decrypt)<BR>> CALL_RXH(ieee80211_rx_h_defragment)<BR>> CALL_RXH(ieee80211_rx_h_michael_mic_verify)<BR>><BR>><BR>> My question is, why not just call the functions directly like:<BR>><BR>> ieee80211_rx_h_check_more_data(rx);<BR>> ieee80211_rx_h_uapsd_and_pspoll(rx);<BR>><BR>> ...<BR>><BR>> Is it just for the sake of outlining the code for easy reading? Appreciate<BR>> if anyone can explain. Thanks!<BR><BR>Hi,<BR><BR>As you can see above the macro does also error checking.I don't necessarily<BR>think that the code is easier to read, but it can save you some typing.<BR><BR>thanks,<BR>Daniel.<BR><BR>_______________________________________________<BR>Kernelnewbies mailing list<BR>Kernelnewbies@kernelnewbies.org<BR>http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<BR></BODY></HTML>