Skip to contentSkip to conversation

kbuild: remove -Wdeclaration-after-statement

RFC PATCH In review Amerigo Wang 5 participants 7 messages Sep 23, 2009 – Sep 26, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 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. :)

Cc Sam Ravnborg <[email protected]>

---

Makefile +0 -3
index 433493a..038bda2 100644
@@ -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,)
 
#1 lore raw
Quoted 16 lines · Amerigo Wang

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. :)

Cc Sam Ravnborg <[email protected]>

---

Makefile +0 -0
index 433493a..038bda2 100644

Makefile endif · line 563

Quoted 8 lines
Makefile +0 -3
@@ -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.

#2 lore raw
In reply to Amerigo Wang

Hi,

Quoted 3 lines · Amerigo Wang

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 .

Quoted 2 lines

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.

Quoted 9 lines
Cc Sam Ravnborg <[email protected]>

---

Makefile +0 -0
index 433493a..038bda2 100644

Makefile endif · line 563

Quoted 8 lines
Makefile +0 -3
@@ -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

#3 lore raw
In reply to Amerigo Wang
Quoted 6 lines · Amerigo Wang

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

#4 lore raw
Quoted 9 lines · Sam Ravnborg
Quoted 5 lines · Amerigo Wang

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.

Quoted 2 lines

(*) 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

#5 lore raw
Quoted 11 lines · Randy Dunlap
Quoted 9 lines · Sam Ravnborg
Quoted 5 lines · Amerigo Wang

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.

Quoted 7 lines

Agreed.

Quoted 2 lines

(*) 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

#6 lore raw
In reply to Sam Ravnborg
Quoted 4 lines · Sam Ravnborg
Quoted 3 lines · Amerigo Wang

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

Quoted 8 lines
Quoted 2 lines

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!