2009-09-26 12:28:06

by Bart Van Assche

[permalink] [raw]
Subject: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
with sparse (make C=2) triggers a sparse warning on code that uses the
kmemcheck_annotate_bitfield() macro. An example of such a warning:

include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement

Signed-off-by: Bart Van Assche <[email protected]>
Cc: Vegard Nossum <[email protected]>
Cc: Andrew Morton <[email protected]>

--- linux-2.6.31.1/include/linux/kmemcheck-orig.h 2009-09-26 13:53:44.000000000 +0200
+++ linux-2.6.31.1/include/linux/kmemcheck.h 2009-09-26 13:53:56.000000000 +0200
@@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
int name##_end[0];

#define kmemcheck_annotate_bitfield(ptr, name) \
- do if (ptr) { \
+ do { if (ptr) { \
int _n = (long) &((ptr)->name##_end) \
- (long) &((ptr)->name##_begin); \
BUILD_BUG_ON(_n < 0); \
\
kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
- } while (0)
+ } } while (0)

#define kmemcheck_annotate_variable(var) \
do { \


2009-10-02 06:48:58

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

On Sat, Sep 26, 2009 at 2:28 PM, Bart Van Assche
<[email protected]> wrote:
>
> Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
> with sparse (make C=2) triggers a sparse warning on code that uses the
> kmemcheck_annotate_bitfield() macro. An example of such a warning:
>
> include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement
>
> Signed-off-by: Bart Van Assche <[email protected]>
> Cc: Vegard Nossum <[email protected]>
> Cc: Andrew Morton <[email protected]>
>
> --- linux-2.6.31.1/include/linux/kmemcheck-orig.h ? ? ? 2009-09-26 13:53:44.000000000 +0200
> +++ linux-2.6.31.1/include/linux/kmemcheck.h ? ?2009-09-26 13:53:56.000000000 +0200
> @@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
> ? ? ? ?int name##_end[0];
>
> ?#define kmemcheck_annotate_bitfield(ptr, name) ? ? ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? do if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? do { if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ?int _n = (long) &((ptr)->name##_end) ? ? ? ? ? ? ? ? ? ?\
> ? ? ? ? ? ? ? ? ? ? ? ?- (long) &((ptr)->name##_begin); ? ? ? ? ? ? ? ?\
> ? ? ? ? ? ? ? ?BUILD_BUG_ON(_n < 0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> ? ? ? ? ? ? ? ?kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
> - ? ? ? } while (0)
> + ? ? ? } } while (0)
>
> ?#define kmemcheck_annotate_variable(var) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ?do { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\

(ping)

Did anyone already have the time to review the patch above ?

Bart.

2009-10-02 07:51:17

by Vegard Nossum

[permalink] [raw]
Subject: Re: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

2009/10/2 Bart Van Assche <[email protected]>:> On Sat, Sep 26, 2009 at 2:28 PM, Bart Van Assche> <[email protected]> wrote:>>>> Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig>> with sparse (make C=2) triggers a sparse warning on code that uses the>> kmemcheck_annotate_bitfield() macro. An example of such a warning:>>>> include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement>>>> Signed-off-by: Bart Van Assche <[email protected]>>> Cc: Vegard Nossum <[email protected]>>> Cc: Andrew Morton <[email protected]>>>>> --- linux-2.6.31.1/include/linux/kmemcheck-orig.h       2009-09-26 13:53:44.000000000 +0200>> +++ linux-2.6.31.1/include/linux/kmemcheck.h    2009-09-26 13:53:56.000000000 +0200>> @@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia>>        int name##_end[0];>>>>  #define kmemcheck_annotate_bitfield(ptr, name)                         \>> -       do if (ptr) {                                                   \>> +       do { if (ptr) {                                                 \>>                int _n = (long) &((ptr)->name##_end)                    \>>                        - (long) &((ptr)->name##_begin);                \>>                BUILD_BUG_ON(_n < 0);                                   \>>                                                                        \>>                kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \>> -       } while (0)>> +       } } while (0)>>>>  #define kmemcheck_annotate_variable(var)                               \>>        do {                                                            \>> (ping)>> Did anyone already have the time to review the patch above ?>> Bart.
Hi,
A patch for this problem has already been applied in latest mainline.Thanks anyway, and sorry for not responding sooner.

Vegard????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2009-10-14 07:07:05

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

On Fri, Oct 2, 2009 at 9:51 AM, Vegard Nossum <[email protected]> wrote:
>
> 2009/10/2 Bart Van Assche <[email protected]>:
> > On Sat, Sep 26, 2009 at 2:28 PM, Bart Van Assche
> > <[email protected]> wrote:
> >>
> >> Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
> >> with sparse (make C=2) triggers a sparse warning on code that uses the
> >> kmemcheck_annotate_bitfield() macro. An example of such a warning:
> >>
> >> include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement
> >>
> >> Signed-off-by: Bart Van Assche <[email protected]>
> >> Cc: Vegard Nossum <[email protected]>
> >> Cc: Andrew Morton <[email protected]>
> >>
> >> --- linux-2.6.31.1/include/linux/kmemcheck-orig.h ? ? ? 2009-09-26 13:53:44.000000000 +0200
> >> +++ linux-2.6.31.1/include/linux/kmemcheck.h ? ?2009-09-26 13:53:56.000000000 +0200
> >> @@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
> >> ? ? ? ?int name##_end[0];
> >>
> >> ?#define kmemcheck_annotate_bitfield(ptr, name) ? ? ? ? ? ? ? ? ? ? ? ? \
> >> - ? ? ? do if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> >> + ? ? ? do { if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> >> ? ? ? ? ? ? ? ?int _n = (long) &((ptr)->name##_end) ? ? ? ? ? ? ? ? ? ?\
> >> ? ? ? ? ? ? ? ? ? ? ? ?- (long) &((ptr)->name##_begin); ? ? ? ? ? ? ? ?\
> >> ? ? ? ? ? ? ? ?BUILD_BUG_ON(_n < 0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> >> ? ? ? ? ? ? ? ?kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
> >> - ? ? ? } while (0)
> >> + ? ? ? } } while (0)
> >>
> >> ?#define kmemcheck_annotate_variable(var) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> >> ? ? ? ?do { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> >
> > (ping)
> >
> > Did anyone already have the time to review the patch above ?
>
> A patch for this problem has already been applied in latest mainline.

Unfortunately this issue is still present in 2.6.31.4, which has been
released on October 12 (yesterday). Is the patch that has been applied
in the mainline kernel suitable for backporting ?

Bart.

2009-10-14 11:27:24

by Vegard Nossum

[permalink] [raw]
Subject: Re: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

2009/10/14 Bart Van Assche <[email protected]>:
> On Fri, Oct 2, 2009 at 9:51 AM, Vegard Nossum <[email protected]> wrote:
>>
>> 2009/10/2 Bart Van Assche <[email protected]>:
>> > On Sat, Sep 26, 2009 at 2:28 PM, Bart Van Assche
>> > <[email protected]> wrote:
>> >>
>> >> Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
>> >> with sparse (make C=2) triggers a sparse warning on code that uses the
>> >> kmemcheck_annotate_bitfield() macro. An example of such a warning:
>> >>
>> >> include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement
>> >>
>> >> Signed-off-by: Bart Van Assche <[email protected]>
>> >> Cc: Vegard Nossum <[email protected]>
>> >> Cc: Andrew Morton <[email protected]>
>> >>
>> >> --- linux-2.6.31.1/include/linux/kmemcheck-orig.h       2009-09-26 13:53:44.000000000 +0200
>> >> +++ linux-2.6.31.1/include/linux/kmemcheck.h    2009-09-26 13:53:56.000000000 +0200
>> >> @@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
>> >>        int name##_end[0];
>> >>
>> >>  #define kmemcheck_annotate_bitfield(ptr, name)                         \
>> >> -       do if (ptr) {                                                   \
>> >> +       do { if (ptr) {                                                 \
>> >>                int _n = (long) &((ptr)->name##_end)                    \
>> >>                        - (long) &((ptr)->name##_begin);                \
>> >>                BUILD_BUG_ON(_n < 0);                                   \
>> >>                                                                        \
>> >>                kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
>> >> -       } while (0)
>> >> +       } } while (0)
>> >>
>> >>  #define kmemcheck_annotate_variable(var)                               \
>> >>        do {                                                            \
>> >
>> > (ping)
>> >
>> > Did anyone already have the time to review the patch above ?
>>
>> A patch for this problem has already been applied in latest mainline.
>
> Unfortunately this issue is still present in 2.6.31.4, which has been
> released on October 12 (yesterday). Is the patch that has been applied
> in the mainline kernel suitable for backporting ?

I assumed that this wouldn't be suitable for stable kernels, as the
change is purely syntactic. Is there a good reason for applying this
patch to the stable series? Perhaps Greg can answer this (Cced)?


Vegard

2009-10-14 11:52:39

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH 2.6.31.1] include/linux/kmemcheck.h: fix a sparse warning

On Wed, Oct 14, 2009 at 1:26 PM, Vegard Nossum <[email protected]> wrote:
> 2009/10/14 Bart Van Assche <[email protected]>:
>> On Fri, Oct 2, 2009 at 9:51 AM, Vegard Nossum <[email protected]> wrote:
>>>
>>> 2009/10/2 Bart Van Assche <[email protected]>:
>>> > On Sat, Sep 26, 2009 at 2:28 PM, Bart Van Assche
>>> > <[email protected]> wrote:
>>> >>
>>> >> Checking a 2.6.31.1 kernel configured with allyesconfig/allmodconfig
>>> >> with sparse (make C=2) triggers a sparse warning on code that uses the
>>> >> kmemcheck_annotate_bitfield() macro. An example of such a warning:
>>> >>
>>> >> include/net/inet_sock.h:208:17: warning: do-while statement is not a compound statement
>>> >>
>>> >> Signed-off-by: Bart Van Assche <[email protected]>
>>> >> Cc: Vegard Nossum <[email protected]>
>>> >> Cc: Andrew Morton <[email protected]>
>>> >>
>>> >> --- linux-2.6.31.1/include/linux/kmemcheck-orig.h ? ? ? 2009-09-26 13:53:44.000000000 +0200
>>> >> +++ linux-2.6.31.1/include/linux/kmemcheck.h ? ?2009-09-26 13:53:56.000000000 +0200
>>> >> @@ -137,13 +137,13 @@ static inline void kmemcheck_mark_initia
>>> >> ? ? ? ?int name##_end[0];
>>> >>
>>> >> ?#define kmemcheck_annotate_bitfield(ptr, name) ? ? ? ? ? ? ? ? ? ? ? ? \
>>> >> - ? ? ? do if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> >> + ? ? ? do { if (ptr) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> >> ? ? ? ? ? ? ? ?int _n = (long) &((ptr)->name##_end) ? ? ? ? ? ? ? ? ? ?\
>>> >> ? ? ? ? ? ? ? ? ? ? ? ?- (long) &((ptr)->name##_begin); ? ? ? ? ? ? ? ?\
>>> >> ? ? ? ? ? ? ? ?BUILD_BUG_ON(_n < 0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>>> >> ? ? ? ? ? ? ? ?kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
>>> >> - ? ? ? } while (0)
>>> >> + ? ? ? } } while (0)
>>> >>
>>> >> ?#define kmemcheck_annotate_variable(var) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> >> ? ? ? ?do { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
>>> >
>>> > (ping)
>>> >
>>> > Did anyone already have the time to review the patch above ?
>>>
>>> A patch for this problem has already been applied in latest mainline.
>>
>> Unfortunately this issue is still present in 2.6.31.4, which has been
>> released on October 12 (yesterday). Is the patch that has been applied
>> in the mainline kernel suitable for backporting ?
>
> I assumed that this wouldn't be suitable for stable kernels, as the
> change is purely syntactic. Is there a good reason for applying this
> patch to the stable series? Perhaps Greg can answer this (Cced)?

Which patch are you referring to (commit ID) ?

Bart.