Re: [PATCH] staging: rtl8723bs: cleanup macros within include/rtw_debug.h

From: Phillip Potter
Date: Wed Feb 10 2021 - 12:38:16 EST


On Wed, Feb 10, 2021 at 06:12:54PM +0100, Greg KH wrote:
> On Wed, Feb 10, 2021 at 05:00:03PM +0000, Phillip Potter wrote:
> > Remove do/while loops from DBG_871X, MSG_8192C and DBG_8192C. Also
> > fix opening brace placements and trailing single statement layout within
> > RT_PRINT_DATA, as well as making newline character placement more
> > consistent and removing camel case where possible. Finally, add
> > parentheses for DBG_COUNTER definition.
> >
> > This fixes 3 checkpatch warnings, 5 checkpatch errors and 3 checkpatch
> > checks.
> >
> > Signed-off-by: Phillip Potter <phil@xxxxxxxxxxxxxxxx>
> > ---
> > drivers/staging/rtl8723bs/include/rtw_debug.h | 40 +++++++++----------
> > 1 file changed, 19 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/include/rtw_debug.h b/drivers/staging/rtl8723bs/include/rtw_debug.h
> > index c90adfb87261..d06ac9540cf7 100644
> > --- a/drivers/staging/rtl8723bs/include/rtw_debug.h
> > +++ b/drivers/staging/rtl8723bs/include/rtw_debug.h
> > @@ -201,19 +201,16 @@
> > #ifdef DEBUG
> > #if defined(_dbgdump)
> > #undef DBG_871X
> > - #define DBG_871X(...) do {\
> > - _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
> > - } while (0)
> > + #define DBG_871X(...)\
> > + _dbgdump(DRIVER_PREFIX __VA_ARGS__)
> >
> > #undef MSG_8192C
> > - #define MSG_8192C(...) do {\
> > - _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
> > - } while (0)
> > + #define MSG_8192C(...)\
> > + _dbgdump(DRIVER_PREFIX __VA_ARGS__)
> >
> > #undef DBG_8192C
> > - #define DBG_8192C(...) do {\
> > - _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
> > - } while (0)
> > + #define DBG_8192C(...)\
> > + _dbgdump(DRIVER_PREFIX __VA_ARGS__)
>
> Odd, the do/while is correct here, why is checkpatch complaining about
> it?

The warning it gives me for these is:
WARNING: Single statement macros should not use a do {} while (0) loop

>
> > #endif /* defined(_dbgdump) */
> > #endif /* DEBUG */
> >
> > @@ -235,25 +232,26 @@
> >
> > #if defined(_dbgdump)
> > #undef RT_PRINT_DATA
> > - #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \
> > - if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
> > - { \
> > + #define RT_PRINT_DATA(_comp, _level, _title_string, _hex_data, _hex_data_len) \
> > + do { \
> > + if (((_comp) & GlobalDebugComponents) && ((_level) <= GlobalDebugLevel)) { \
> > int __i; \
>
> This is not the same as the above stuff, when you find yourself writing
> "also" in a changelog text, that's a huge hint you should break the
> patch up into a patch series.
>
> Please do that here, this is too much for one patch.
>
> thanks,
>
> greg k-h

Thank you for the feedback, I'll do this - shall I leave out the
do/while stuff if you're saying checkpatch is wrong?

Regards,
Phil