2009-09-23 09:38:45

by Cong Wang

[permalink] [raw]
Subject: [RFC Patch] kbuild: remove -Wdeclaration-after-statement


I got lots of "ISO C90 forbids mixed declarations and code" warnings
during compile today's kernel.

I think we can remove the gcc option '-Wdeclaration-after-statement'
now, since we already have C99 for 10 years. :)

Signed-off-by: WANG Cong <[email protected]>
Cc: Sam Ravnborg <[email protected]>

---
diff --git a/Makefile b/Makefile
index 433493a..038bda2 100644
--- a/Makefile
+++ b/Makefile
@@ -559,9 +559,6 @@ endif
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)

-# warn about C99 declaration after statement
-KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
-
# disable pointer signed / unsigned warnings in gcc 4.0
KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)


2009-09-23 10:20:42

by Mikael Pettersson

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

Amerigo Wang writes:
>
> I got lots of "ISO C90 forbids mixed declarations and code" warnings
> during compile today's kernel.
>
> I think we can remove the gcc option '-Wdeclaration-after-statement'
> now, since we already have C99 for 10 years. :)
>
> Signed-off-by: WANG Cong <[email protected]>
> Cc: Sam Ravnborg <[email protected]>
>
> ---
> diff --git a/Makefile b/Makefile
> index 433493a..038bda2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -559,9 +559,6 @@ endif
> NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
> CHECKFLAGS += $(NOSTDINC_FLAGS)
>
> -# warn about C99 declaration after statement
> -KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
> -
> # disable pointer signed / unsigned warnings in gcc 4.0
> KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)

This is more a matter of coding-style policy than C technicalities.

I happen to hate declarations at random places in the code, so I'd
prefer the offending code to be fixed instead.

2009-09-23 10:42:11

by Johannes Weiner

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

Hi,

On Wed, Sep 23, 2009 at 05:38:01AM -0400, Amerigo Wang wrote:
>
> I got lots of "ISO C90 forbids mixed declarations and code" warnings
> during compile today's kernel.

Yeah, see http://lkml.org/lkml/2009/9/22/585 .

> I think we can remove the gcc option '-Wdeclaration-after-statement'
> now, since we already have C99 for 10 years. :)

It's still ugly and uncommon to have variable declarations appear
randomly in block bodies, please keep the warning.

> Signed-off-by: WANG Cong <[email protected]>
> Cc: Sam Ravnborg <[email protected]>
>
> ---
> diff --git a/Makefile b/Makefile
> index 433493a..038bda2 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -559,9 +559,6 @@ endif
> NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
> CHECKFLAGS += $(NOSTDINC_FLAGS)
>
> -# warn about C99 declaration after statement
> -KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
> -
> # disable pointer signed / unsigned warnings in gcc 4.0
> KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)

Hannes

2009-09-23 10:51:58

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

On Wed, Sep 23, 2009 at 05:38:01AM -0400, Amerigo Wang wrote:
>
> I got lots of "ISO C90 forbids mixed declarations and code" warnings
> during compile today's kernel.
>
> I think we can remove the gcc option '-Wdeclaration-after-statement'
> now, since we already have C99 for 10 years. :)

This is a matter of style more than what C99 allows.
Kernel style is to fobid this(*) so we keep the warning.

(*) Based on reading several threads where this has
been mentioned - I have no specific references to CodingStyle.

Sam

2009-09-25 20:18:13

by Randy Dunlap

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

Sam Ravnborg wrote:
> On Wed, Sep 23, 2009 at 05:38:01AM -0400, Amerigo Wang wrote:
>> I got lots of "ISO C90 forbids mixed declarations and code" warnings
>> during compile today's kernel.
>>
>> I think we can remove the gcc option '-Wdeclaration-after-statement'
>> now, since we already have C99 for 10 years. :)
>
> This is a matter of style more than what C99 allows.
> Kernel style is to fobid this(*) so we keep the warning.

Agreed.

> (*) Based on reading several threads where this has
> been mentioned - I have no specific references to CodingStyle.

I've avoided making updates to CodingStyle lately.
Is this one needed?

Thanks,
~Randy

2009-09-25 20:52:26

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

On Fri, Sep 25, 2009 at 01:18:52PM -0700, Randy Dunlap wrote:
> Sam Ravnborg wrote:
> > On Wed, Sep 23, 2009 at 05:38:01AM -0400, Amerigo Wang wrote:
> >> I got lots of "ISO C90 forbids mixed declarations and code" warnings
> >> during compile today's kernel.
> >>
> >> I think we can remove the gcc option '-Wdeclaration-after-statement'
> >> now, since we already have C99 for 10 years. :)
> >
> > This is a matter of style more than what C99 allows.
> > Kernel style is to fobid this(*) so we keep the warning.
>
> Agreed.
>
> > (*) Based on reading several threads where this has
> > been mentioned - I have no specific references to CodingStyle.
>
> I've avoided making updates to CodingStyle lately.
> Is this one needed?
No - CodingStyle should be general stuff.

Sam

2009-09-26 01:04:25

by Cong Wang

[permalink] [raw]
Subject: Re: [RFC Patch] kbuild: remove -Wdeclaration-after-statement

Sam Ravnborg wrote:
> On Wed, Sep 23, 2009 at 05:38:01AM -0400, Amerigo Wang wrote:
>> I got lots of "ISO C90 forbids mixed declarations and code" warnings
>> during compile today's kernel.
>>
>> I think we can remove the gcc option '-Wdeclaration-after-statement'
>> now, since we already have C99 for 10 years. :)
>
> This is a matter of style more than what C99 allows.
> Kernel style is to fobid this(*) so we keep the warning.
>
> (*) Based on reading several threads where this has
> been mentioned - I have no specific references to CodingStyle.

Ah, Ok, no problem.

Thanks, everyone!