2021-03-26 09:11:16

by Fabio Aiuto

[permalink] [raw]
Subject: [PATCH 04/15] staging: rtl8723bs: put parentheses on macros with complex values in include/basic_types.h

fix the following checkpatch warnings:

ERROR: Macros with complex values should be enclosed in parentheses
154: FILE: drivers/staging/rtl8723bs/include/basic_types.h:154:
+#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
--
ERROR: Macros with multiple statements should be enclosed in
a do - while loop
161: FILE: drivers/staging/rtl8723bs/include/basic_types.h:161:
+#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
--
ERROR: Macros with complex values should be enclosed in parentheses
168: FILE: drivers/staging/rtl8723bs/include/basic_types.h:168:
+#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \

parentheses solution preferred for all fixes and made macros more
readables

Signed-off-by: Fabio Aiuto <[email protected]>
---
.../staging/rtl8723bs/include/basic_types.h | 30 +++++++++++--------
1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index 76304086107a..5054c2e3384c 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -152,24 +152,30 @@
/* Set subfield of little-endian 4-byte value to specified value. */
/* */
#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
- *((u32 *)(__pstart)) = \
- ( \
- LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
- ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
+ (\
+ *((u32 *)(__pstart)) = \
+ ( \
+ LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
+ ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
+ )\
)

#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
- *((u16 *)(__pstart)) = \
- ( \
- LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
- ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
+ (\
+ *((u16 *)(__pstart)) = \
+ ( \
+ LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \
+ ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \
+ )\
);

#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
- *((u8 *)(__pstart)) = EF1BYTE \
- ( \
- LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \
- ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
+ (\
+ *((u8 *)(__pstart)) = EF1BYTE \
+ ( \
+ LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \
+ ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \
+ )\
)

#define LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
--
2.20.1


2021-03-26 10:06:34

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 04/15] staging: rtl8723bs: put parentheses on macros with complex values in include/basic_types.h

On Fri, Mar 26, 2021 at 10:09:11AM +0100, Fabio Aiuto wrote:
> fix the following checkpatch warnings:
>
> ERROR: Macros with complex values should be enclosed in parentheses
> 154: FILE: drivers/staging/rtl8723bs/include/basic_types.h:154:
> +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> --
> ERROR: Macros with multiple statements should be enclosed in
> a do - while loop
> 161: FILE: drivers/staging/rtl8723bs/include/basic_types.h:161:
> +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
> --
> ERROR: Macros with complex values should be enclosed in parentheses
> 168: FILE: drivers/staging/rtl8723bs/include/basic_types.h:168:
> +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
>
> parentheses solution preferred for all fixes and made macros more
> readables
>
> Signed-off-by: Fabio Aiuto <[email protected]>
> ---
> .../staging/rtl8723bs/include/basic_types.h | 30 +++++++++++--------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
> index 76304086107a..5054c2e3384c 100644
> --- a/drivers/staging/rtl8723bs/include/basic_types.h
> +++ b/drivers/staging/rtl8723bs/include/basic_types.h
> @@ -152,24 +152,30 @@
> /* Set subfield of little-endian 4-byte value to specified value. */
> /* */
> #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> - *((u32 *)(__pstart)) = \
> - ( \
> - LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> - ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> + (\
> + *((u32 *)(__pstart)) = \
> + ( \
> + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> + )\
> )
>

These macros are terrible and this makes it uglier. Better to just
ignore checkpatch until we can figure out a way to re-write this
properly.

regards,
dan carpenter

2021-03-26 11:14:25

by Fabio Aiuto

[permalink] [raw]
Subject: Re: [PATCH 04/15] staging: rtl8723bs: put parentheses on macros with complex values in include/basic_types.h

On Fri, Mar 26, 2021 at 01:04:08PM +0300, Dan Carpenter wrote:
> On Fri, Mar 26, 2021 at 10:09:11AM +0100, Fabio Aiuto wrote:
> > fix the following checkpatch warnings:
> >
> > ERROR: Macros with complex values should be enclosed in parentheses
> > 154: FILE: drivers/staging/rtl8723bs/include/basic_types.h:154:
> > +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > --
> > ERROR: Macros with multiple statements should be enclosed in
> > a do - while loop
> > 161: FILE: drivers/staging/rtl8723bs/include/basic_types.h:161:
> > +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > --
> > ERROR: Macros with complex values should be enclosed in parentheses
> > 168: FILE: drivers/staging/rtl8723bs/include/basic_types.h:168:
> > +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
> >
> > parentheses solution preferred for all fixes and made macros more
> > readables
> >
> > Signed-off-by: Fabio Aiuto <[email protected]>
> > ---
> > .../staging/rtl8723bs/include/basic_types.h | 30 +++++++++++--------
> > 1 file changed, 18 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
> > index 76304086107a..5054c2e3384c 100644
> > --- a/drivers/staging/rtl8723bs/include/basic_types.h
> > +++ b/drivers/staging/rtl8723bs/include/basic_types.h
> > @@ -152,24 +152,30 @@
> > /* Set subfield of little-endian 4-byte value to specified value. */
> > /* */
> > #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > - *((u32 *)(__pstart)) = \
> > - ( \
> > - LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> > - ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> > + (\
> > + *((u32 *)(__pstart)) = \
> > + ( \
> > + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> > + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> > + )\
> > )
> >
>
> These macros are terrible and this makes it uglier. Better to just
> ignore checkpatch until we can figure out a way to re-write this
> properly.
>
> regards,
> dan carpenter
>

I see, will drop the patch for now.

thanks,

fabio

2021-03-26 14:11:47

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 04/15] staging: rtl8723bs: put parentheses on macros with complex values in include/basic_types.h

On Fri, Mar 26, 2021 at 12:12:42PM +0100, Fabio Aiuto wrote:
> On Fri, Mar 26, 2021 at 01:04:08PM +0300, Dan Carpenter wrote:
> > On Fri, Mar 26, 2021 at 10:09:11AM +0100, Fabio Aiuto wrote:
> > > fix the following checkpatch warnings:
> > >
> > > ERROR: Macros with complex values should be enclosed in parentheses
> > > 154: FILE: drivers/staging/rtl8723bs/include/basic_types.h:154:
> > > +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > > --
> > > ERROR: Macros with multiple statements should be enclosed in
> > > a do - while loop
> > > 161: FILE: drivers/staging/rtl8723bs/include/basic_types.h:161:
> > > +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > > --
> > > ERROR: Macros with complex values should be enclosed in parentheses
> > > 168: FILE: drivers/staging/rtl8723bs/include/basic_types.h:168:
> > > +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > >
> > > parentheses solution preferred for all fixes and made macros more
> > > readables
> > >
> > > Signed-off-by: Fabio Aiuto <[email protected]>
> > > ---
> > > .../staging/rtl8723bs/include/basic_types.h | 30 +++++++++++--------
> > > 1 file changed, 18 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
> > > index 76304086107a..5054c2e3384c 100644
> > > --- a/drivers/staging/rtl8723bs/include/basic_types.h
> > > +++ b/drivers/staging/rtl8723bs/include/basic_types.h
> > > @@ -152,24 +152,30 @@
> > > /* Set subfield of little-endian 4-byte value to specified value. */
> > > /* */
> > > #define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \
> > > - *((u32 *)(__pstart)) = \
> > > - ( \
> > > - LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> > > - ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> > > + (\
> > > + *((u32 *)(__pstart)) = \
> > > + ( \
> > > + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \
> > > + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \
> > > + )\
> > > )
> > >
> >
> > These macros are terrible and this makes it uglier. Better to just
> > ignore checkpatch until we can figure out a way to re-write this
> > properly.
> >
> > regards,
> > dan carpenter
> >
>
> I see, will drop the patch for now.

Please resend a v2 set of this series so I know what to apply here...

thanks,

greg k-h