Skip to contentSkip to conversation

kbuild: enforce -Werror=unused-result

PATCH Superseded Olaf Hering 2 participants 3 messages Nov 17, 2020 – Dec 21, 2020 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: enforce -Werror=unused-result

It is a hard error if a return value is ignored.
In case the return value has no meaning, remove the attribute.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index e2c3f65c4721..c7f9acffad42 100644
@@ -497,7 +497,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
-		   -Werror=return-type -Wno-format-security \
+		   -Werror=return-type -Werror=unused-result -Wno-format-security \
 		   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
#1 lore raw
Quoted 5 lines · Olaf Hering

It is a hard error if a return value is ignored.
In case the return value has no meaning, remove the attribute.

Applied to linux-kbuild.
Thanks.

Quoted 17 lines
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index e2c3f65c4721..c7f9acffad42 100644
@@ -497,7 +497,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
                   -Werror=implicit-function-declaration -Werror=implicit-int \
-                  -Werror=return-type -Wno-format-security \
+                  -Werror=return-type -Werror=unused-result -Wno-format-security \
                   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 10 lines · Masahiro Yamada
Quoted 5 lines · Olaf Hering

It is a hard error if a return value is ignored.
In case the return value has no meaning, remove the attribute.

Applied to linux-kbuild.
Thanks.

I will postpone this by the next MW.

Some instances of __must_check violation are still remaining, which end up with build breakages.

Quoted 24 lines
Quoted 10 lines
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index e2c3f65c4721..c7f9acffad42 100644

Makefile KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE · line 503

Quoted 8 lines
Makefile +1 -1
@@ -497,7 +497,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
                   -Werror=implicit-function-declaration -Werror=implicit-int \
-                  -Werror=return-type -Wno-format-security \
+                  -Werror=return-type -Werror=unused-result -Wno-format-security \
                   -std=gnu89
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada