[PATCH] staging: fix macros with multiple statements in rtl8723bs/core/rtw_security.c

Jamie Huang jamienstar at 163.com
Sun May 7 10:23:14 UTC 2017


On Sat, 6 May 2017 20:20:57 -0700
Greg KH <gregkh at linuxfoundation.org> wrote:

> On Fri, May 05, 2017 at 02:00:43AM +0800, Jamie Huang wrote:
> > ERROR: Macros with multiple statements should be enclosed in a do -
> > while loop Detected by scripts/checkpatch.pl -f
> > 
> > Signed-off-by: Jamie Huang <jamienstar at 163.com>
> > ---
> >  drivers/staging/rtl8723bs/core/rtw_security.c | 34
> > +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10
> > deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c
> > b/drivers/staging/rtl8723bs/core/rtw_security.c index
> > e832f16..c4558db 100644 ---
> > a/drivers/staging/rtl8723bs/core/rtw_security.c +++
> > b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -38,52 +38,64 @@
> > const char *security_type_str(u8 value) 
> >  #ifdef DBG_SW_SEC_CNT
> >  #define WEP_SW_ENC_CNT_INC(sec, ra) \
> > +do {	\
> >  	if (is_broadcast_mac_addr(ra)) \
> >  		sec->wep_sw_enc_cnt_bc++; \
> >  	else if (is_multicast_mac_addr(ra)) \
> >  		sec->wep_sw_enc_cnt_mc++; \
> >  	else \
> > -		sec->wep_sw_enc_cnt_uc++;
> > +		sec->wep_sw_enc_cnt_uc++; \
> > +} while (0)  
> 
> Ick, these are horrible, can you just make them an inline function
> instead?
> 
> thanks,
> 
> greg k-h

Thank you for reply. Inline function may be a better choice. Does this mean that we should use inline instead of do-while macro in new kernel source code?



More information about the devel mailing list