Skip to contentSkip to conversation

add -Werror-implicit-function-declaration to CFLAGS

PATCH In review Adrian Bunk 2 participants 5 messages Aug 30, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add -Werror-implicit-function-declaration to CFLAGS

Currently, using an undeclared function gives a compile warning, but it can lead to a link or even a runtime error.

With -Werror-implicit-function-declaration, we are getting an immediate compile error instead.

This patch also removes some unneeded spaces between two tabs in the following line.

---

This patch was already sent on:
- 30 Jul 2005

Makefile renamed from Makefile.old +2 -1
@@ -351,7 +351,8 @@
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
 CFLAGS 		:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-	  	   -fno-strict-aliasing -fno-common \
+		   -Werror-implicit-function-declaration \
+		   -fno-strict-aliasing -fno-common \
 		   -ffreestanding
 AFLAGS		:= -D__ASSEMBLY__
 
#1 lore raw
Quoted 5 lines · Adrian Bunk

Currently, using an undeclared function gives a compile warning, but it can lead to a link or even a runtime error.

With -Werror-implicit-function-declaration, we are getting an immediate compile error instead.

You have to fix CONFIG_SWAP=n as well.

http://lkml.org/lkml/2005/8/6/72

#2 lore raw
Quoted 11 lines · Olaf Hering
Quoted 5 lines · Adrian Bunk

Currently, using an undeclared function gives a compile warning, but it can lead to a link or even a runtime error.

With -Werror-implicit-function-declaration, we are getting an immediate compile error instead.

You have to fix CONFIG_SWAP=n as well.

http://lkml.org/lkml/2005/8/6/72

I don't see any such warning in the 2.6.13 sparc build at Jan's crosscompile page [1], and all my patch does is to turn a warning into an error.

If a #define is using it before the header with the prototype get's #include'd that's no problem as long as the prototype is available when the #define is _used_.

I'm not saying that there aren't cases this patch will break (and my patch shouldn't go into 2.6.14), but your example doesn't seem to cause problems.

cu
Adrian

[1] http://l4x.org/k/?d=6676

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw
Quoted 9 lines · Adrian Bunk
Quoted 8 lines · Olaf Hering
Quoted 5 lines · Adrian Bunk

Currently, using an undeclared function gives a compile warning, but it can lead to a link or even a runtime error.

With -Werror-implicit-function-declaration, we are getting an immediate compile error instead.

Quoted 7 lines
Quoted 3 lines

You have to fix CONFIG_SWAP=n as well.

http://lkml.org/lkml/2005/8/6/72

I don't see any such warning in the 2.6.13 sparc build at Jan's crosscompile page [1], and all my patch does is to turn a warning into an error.

page_cache_release and release_pages will be undefined when compiling arch/ppc/configs/common_defconfig, but not arch/i386/defconfig, with CONFIG_SWAP=n

#4 lore raw
Quoted 4 lines · Olaf Hering

page_cache_release and release_pages will be undefined when compiling arch/ppc/configs/common_defconfig, but not arch/i386/defconfig, with CONFIG_SWAP=n

There will be some compile errors in cases where compilation previously worked because the undefined function wasn't called due to gcc dead code elimination.

We need to fix some code, but I'd strongly prefer this over the possible runtime errors -Werror-implicit-function-declaration prevents in other cases.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed