[PATCH 3/6] [v3] kbuild: turn on -Wrestrict by default

Arnd Bergmann posted 6 patches 1 year, 10 months ago
[PATCH 3/6] [v3] kbuild: turn on -Wrestrict by default
Posted by Arnd Bergmann 1 year, 10 months ago
From: Arnd Bergmann <arnd@arndb.de>

All known -Wrestrict warnings are addressed now, so don't disable the warning
any more.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 scripts/Makefile.extrawarn | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 8b3f5b62b837..95466a04d51b 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -98,7 +98,6 @@ else
 # Suppress them by using -Wno... except for W=1.
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
 KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
-- 
2.39.2
Re: [PATCH 3/6] [v3] kbuild: turn on -Wrestrict by default
Posted by Geert Uytterhoeven 1 year, 8 months ago
Hi Arnd,

On Mon, Apr 15, 2024 at 2:22 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> All known -Wrestrict warnings are addressed now, so don't disable the warning
> any more.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for your patch, which is now commit 06bb7fc0feee32d9 ("kbuild:
turn on -Wrestrict by default") in v6.10-rc1.

With shmobile_defconfig and gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04):

    kernel/kallsyms.c: In function ‘__sprint_symbol.constprop’:
    kernel/kallsyms.c:492:17: warning: ‘strcpy’ source argument is the
same as destination [-Werror=restrict]
      492 |                 strcpy(buffer, name);
          |                 ^~~~~~~~~~~~~~~~~~~~

Reverting the commit fixes the issue.

I assume you just forgot that this depends on "[PATCH] [v5] kallsyms:
rework symbol lookup return codes"?
https://lore.kernel.org/r/20240404143424.3279752-1-arnd@kernel.org

> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -98,7 +98,6 @@ else
>  # Suppress them by using -Wno... except for W=1.
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
> -KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>  KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH 3/6] [v3] kbuild: turn on -Wrestrict by default
Posted by Kees Cook 1 year, 10 months ago
On Mon, Apr 15, 2024 at 02:20:34PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> All known -Wrestrict warnings are addressed now, so don't disable the warning
> any more.

Ah, great! Yes, I know Gatlin was also looking at this and doing a bunch
of builds across compiler versions to verify this was ready to do too.
Gatlin, are you able to provide a "Tested-by:" tag for this patch?

-Kees

> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  scripts/Makefile.extrawarn | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 8b3f5b62b837..95466a04d51b 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -98,7 +98,6 @@ else
>  # Suppress them by using -Wno... except for W=1.
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
>  KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
> -KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>  KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
>  KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
> -- 
> 2.39.2
> 

-- 
Kees Cook