linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: enforce -Werror=unused-result
@ 2021-03-19 14:32 Olaf Hering
  2021-03-25 11:16 ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2021-03-19 14:32 UTC (permalink / raw)
  To: linux-kbuild, linux-kernel; +Cc: Olaf Hering, Masahiro Yamada, Michal Marek

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

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
v2:
  resend

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a28bb374663d..9b7def6db494 100644
--- a/Makefile
+++ b/Makefile
@@ -495,7 +495,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 :=

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] kbuild: enforce -Werror=unused-result
  2021-03-19 14:32 [PATCH v2] kbuild: enforce -Werror=unused-result Olaf Hering
@ 2021-03-25 11:16 ` Olaf Hering
  2021-03-25 16:55   ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2021-03-25 11:16 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: linux-kbuild, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Am Fri, 19 Mar 2021 15:32:31 +0100
schrieb Olaf Hering <olaf@aepfle.de>:

> It is a hard error if a return value is ignored.

The automated builds found only a single error, in load_em86().

Let me know if there are other reasons why the patch was rejected.

Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] kbuild: enforce -Werror=unused-result
  2021-03-25 11:16 ` Olaf Hering
@ 2021-03-25 16:55   ` Masahiro Yamada
  2021-03-25 17:07     ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2021-03-25 16:55 UTC (permalink / raw)
  To: Olaf Hering
  Cc: Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List

On Thu, Mar 25, 2021 at 8:16 PM Olaf Hering <olaf@aepfle.de> wrote:
>
> Am Fri, 19 Mar 2021 15:32:31 +0100
> schrieb Olaf Hering <olaf@aepfle.de>:
>
> > It is a hard error if a return value is ignored.
>
> The automated builds found only a single error, in load_em86().


What about  drivers/net/ethernet/lantiq_etop.c  ?




> Let me know if there are other reasons why the patch was rejected.
>
> Olaf


I got a lot of complaints in the last trial.

It is easy to send a patch like this, but difficult to
make sure that I will not break any CI tests.

Over time, I started to believe keeping this as a warning
is OK.

The same problem happens when you add a new __must_check
annotation. You end up with fixing all the call-sites in advance.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] kbuild: enforce -Werror=unused-result
  2021-03-25 16:55   ` Masahiro Yamada
@ 2021-03-25 17:07     ` Olaf Hering
  2021-03-25 17:32       ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2021-03-25 17:07 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Am Fri, 26 Mar 2021 01:55:41 +0900
schrieb Masahiro Yamada <masahiroy@kernel.org>:

> What about  drivers/net/ethernet/lantiq_etop.c  ?

Nothing complained about it. I guess there is a build-bot for alpha, but none for mips.

> I got a lot of complaints in the last trial.

Why did you get complains, instead of me?


What is the "must" in "__must_check" worth if it is not enforced...

Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] kbuild: enforce -Werror=unused-result
  2021-03-25 17:07     ` Olaf Hering
@ 2021-03-25 17:32       ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2021-03-25 17:32 UTC (permalink / raw)
  To: Olaf Hering
  Cc: Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List

On Fri, Mar 26, 2021 at 2:07 AM Olaf Hering <olaf@aepfle.de> wrote:
>
> Am Fri, 26 Mar 2021 01:55:41 +0900
> schrieb Masahiro Yamada <masahiroy@kernel.org>:
>
> > What about  drivers/net/ethernet/lantiq_etop.c  ?
>
> Nothing complained about it. I guess there is a build-bot for alpha, but none for mips.
>
> > I got a lot of complaints in the last trial.
>
> Why did you get complains, instead of me?
>
>
> What is the "must" in "__must_check" worth if it is not enforced...
>
> Olaf


In hindsight, __must_check may not be a perfect name.

Miguel suggested __nodiscard to get along with:
https://en.cppreference.com/w/c/language/attributes/nodiscard

It is not enforcing. Just a compiler warning.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-25 17:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 14:32 [PATCH v2] kbuild: enforce -Werror=unused-result Olaf Hering
2021-03-25 11:16 ` Olaf Hering
2021-03-25 16:55   ` Masahiro Yamada
2021-03-25 17:07     ` Olaf Hering
2021-03-25 17:32       ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).