Skip to contentSkip to conversation

kbuild: enforce -Werror=return-type

PATCH Superseded Olaf Hering 2 participants 2 messages Oct 5, 2020 – Oct 11, 2020 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: enforce -Werror=return-type

Catch errors which at least gcc tolerates by default:
warning: 'return' with no value, in function returning non-void [-Wreturn-type]

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index f84d7e4ca0be..7b2e63e7be18 100644
@@ -942,6 +942,9 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
 # enforce correct pointer usage
 KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 
+# enforce correct return type
+KBUILD_CFLAGS   += $(call cc-option,-Werror=return-type)
+
 # Require designated initializers for all marked structures
 KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
#1 lore raw
Quoted 14 lines · Olaf Hering

Catch errors which at least gcc tolerates by default:
warning: 'return' with no value, in function returning non-void [-Wreturn-type]

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +0 -0
index f84d7e4ca0be..7b2e63e7be18 100644

Makefile KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) · line 947

Quoted 6 lines
Makefile +3 -0
@@ -942,6 +942,9 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=date-time)
 # enforce correct pointer usage
 KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 
+# enforce correct return type
+KBUILD_CFLAGS   += $(call cc-option,-Werror=return-type)
+

cc-option is unneeded because the minimal supported versions of GCC/Clang support -Werror=return-type.

You can hard-code and add it around line 500.

Quoted 3 lines
Makefile +0 -0
 # Require designated initializers for all marked structures
 KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
Signature · 2 lines
Best Regards
Masahiro Yamada