Skip to contentSkip to conversation

kbuild: Enable -Wuninitialized

PATCH In review Nathan Chancellor 3 participants 3 messages Jun 14, 2019 – Jun 20, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Enable -Wuninitialized

This helps fine very dodgy behavior through both -Wuninitialized (warning that a variable is always uninitialized) and -Wsometimes-uninitialized (warning that a variable is sometimes uninitialized, like GCC's -Wmaybe-uninitialized). These warnings catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/[email protected]/

We very much want to catch these so turn this warning on so that CI is aware of it.

---
 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)
scripts/Makefile.extrawarn +0 -1
index 98081ab300e5..699683a7c116 100644
@@ -71,6 +71,5 @@ KBUILD_CFLAGS += -Wno-unused-value
 KBUILD_CFLAGS += -Wno-format
 KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += -Wno-format-zero-length
-KBUILD_CFLAGS += -Wno-uninitialized
 endif
 endif
Signature · 1 line
2.22.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Nathan Chancellor

This helps fine very dodgy behavior through both -Wuninitialized (warning that a variable is always uninitialized) and -Wsometimes-uninitialized (warning that a variable is sometimes uninitialized, like GCC's -Wmaybe-uninitialized). These warnings catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/[email protected]/

or this one, which was my favorite, and quite insidious from an underhanded C contest perspective.
https://lore.kernel.org/lkml/[email protected]/

Thank you very much for all the hard work you did tracking done and fixing all of the cases we could find. I very much look forward to this patch as the capstone to all that work.

Quoted 24 lines

We very much want to catch these so turn this warning on so that CI is aware of it.

---
 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)
scripts/Makefile.extrawarn +0 -2
index 98081ab300e5..699683a7c116 100644
@@ -71,6 +71,5 @@ KBUILD_CFLAGS += -Wno-unused-value
 KBUILD_CFLAGS += -Wno-format
 KBUILD_CFLAGS += -Wno-sign-compare
 KBUILD_CFLAGS += -Wno-format-zero-length
-KBUILD_CFLAGS += -Wno-uninitialized
 endif
 endif
--

2.22.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
In reply to Nathan Chancellor
Quoted 7 lines · Nathan Chancellor

This helps fine very dodgy behavior through both -Wuninitialized (warning that a variable is always uninitialized) and -Wsometimes-uninitialized (warning that a variable is sometimes uninitialized, like GCC's -Wmaybe-uninitialized). These warnings catch things that GCC doesn't such as:

Quoted 8 lines

https://lore.kernel.org/lkml/[email protected]/

We very much want to catch these so turn this warning on so that CI is aware of it.

---

Applied to linux-kbuild.
Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada