All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next] static_call: fix unused variable warn w/o MODULE
@ 2021-03-26 10:50 Matthieu Baerts
  2021-03-26 11:12 ` Peter Zijlstra
  2021-04-09 11:30 ` [tip: locking/core] static_call: Fix " tip-bot2 for Matthieu Baerts
  0 siblings, 2 replies; 3+ messages in thread
From: Matthieu Baerts @ 2021-03-26 10:50 UTC (permalink / raw)
  To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Steven Rostedt,
	Ard Biesheuvel, Jarkko Sakkinen
  Cc: Matthieu Baerts, linux-kernel

Here is the warning converted as error and reported by GCC:

  kernel/static_call.c: In function ‘__static_call_update’:
  kernel/static_call.c:153:18: error: unused variable ‘mod’ [-Werror=unused-variable]
    153 |   struct module *mod = site_mod->mod;
        |                  ^~~
  cc1: all warnings being treated as errors
  make[1]: *** [scripts/Makefile.build:271: kernel/static_call.o] Error 1

This is simply because since recently, we no longer use 'mod' variable
elsewhere if MODULE is unset.

When using 'make tinyconfig' to generate the default kconfig, MODULE is
unset.

There are different ways to fix this warning. Here I tried to minimised
the number of modified lines and not add more #ifdef. We could also move
the declaration of the 'mod' variable inside the if-statement or
directly use site_mod->mod.

Fixes: 698bacefe993 ("static_call: Align static_call_is_init() patching condition")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---

Notes:
    Feel free to modify this patch directly if you prefer. I can of course
    send a new version if needed.

 kernel/static_call.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 2c5950b0b90e..723fcc9d20db 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
 		stop = __stop_static_call_sites;
 
-#ifdef CONFIG_MODULES
 		if (mod) {
+#ifdef CONFIG_MODULES
 			stop = mod->static_call_sites +
 			       mod->num_static_call_sites;
 			init = mod->state == MODULE_STATE_COMING;
-		}
 #endif
+		}
 
 		for (site = site_mod->sites;
 		     site < stop && static_call_key(site) == key; site++) {
-- 
2.30.2


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

* Re: [PATCH mptcp-next] static_call: fix unused variable warn w/o MODULE
  2021-03-26 10:50 [PATCH mptcp-next] static_call: fix unused variable warn w/o MODULE Matthieu Baerts
@ 2021-03-26 11:12 ` Peter Zijlstra
  2021-04-09 11:30 ` [tip: locking/core] static_call: Fix " tip-bot2 for Matthieu Baerts
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2021-03-26 11:12 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: Josh Poimboeuf, Jason Baron, Steven Rostedt, Ard Biesheuvel,
	Jarkko Sakkinen, linux-kernel

On Fri, Mar 26, 2021 at 11:50:23AM +0100, Matthieu Baerts wrote:
> Here is the warning converted as error and reported by GCC:
> 
>   kernel/static_call.c: In function ‘__static_call_update’:
>   kernel/static_call.c:153:18: error: unused variable ‘mod’ [-Werror=unused-variable]
>     153 |   struct module *mod = site_mod->mod;
>         |                  ^~~
>   cc1: all warnings being treated as errors
>   make[1]: *** [scripts/Makefile.build:271: kernel/static_call.o] Error 1
> 
> This is simply because since recently, we no longer use 'mod' variable
> elsewhere if MODULE is unset.
> 
> When using 'make tinyconfig' to generate the default kconfig, MODULE is
> unset.
> 
> There are different ways to fix this warning. Here I tried to minimised
> the number of modified lines and not add more #ifdef. We could also move
> the declaration of the 'mod' variable inside the if-statement or
> directly use site_mod->mod.
> 
> Fixes: 698bacefe993 ("static_call: Align static_call_is_init() patching condition")
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
> 
> Notes:
>     Feel free to modify this patch directly if you prefer. I can of course
>     send a new version if needed.

Ah, I had indeed meant to take a look at this, but hadn't come around to
it. I think this is as nice a solution as there is, so let me go apply
this.

>  kernel/static_call.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/static_call.c b/kernel/static_call.c
> index 2c5950b0b90e..723fcc9d20db 100644
> --- a/kernel/static_call.c
> +++ b/kernel/static_call.c
> @@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
>  
>  		stop = __stop_static_call_sites;
>  
> -#ifdef CONFIG_MODULES
>  		if (mod) {
> +#ifdef CONFIG_MODULES
>  			stop = mod->static_call_sites +
>  			       mod->num_static_call_sites;
>  			init = mod->state == MODULE_STATE_COMING;
> -		}
>  #endif
> +		}
>  


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

* [tip: locking/core] static_call: Fix unused variable warn w/o MODULE
  2021-03-26 10:50 [PATCH mptcp-next] static_call: fix unused variable warn w/o MODULE Matthieu Baerts
  2021-03-26 11:12 ` Peter Zijlstra
@ 2021-04-09 11:30 ` tip-bot2 for Matthieu Baerts
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Matthieu Baerts @ 2021-04-09 11:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Matthieu Baerts, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     7d95f22798ecea513f37b792b39fec4bcf20fec3
Gitweb:        https://git.kernel.org/tip/7d95f22798ecea513f37b792b39fec4bcf20fec3
Author:        Matthieu Baerts <matthieu.baerts@tessares.net>
AuthorDate:    Fri, 26 Mar 2021 11:50:23 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 09 Apr 2021 13:22:12 +02:00

static_call: Fix unused variable warn w/o MODULE

Here is the warning converted as error and reported by GCC:

  kernel/static_call.c: In function ‘__static_call_update’:
  kernel/static_call.c:153:18: error: unused variable ‘mod’ [-Werror=unused-variable]
    153 |   struct module *mod = site_mod->mod;
        |                  ^~~
  cc1: all warnings being treated as errors
  make[1]: *** [scripts/Makefile.build:271: kernel/static_call.o] Error 1

This is simply because since recently, we no longer use 'mod' variable
elsewhere if MODULE is unset.

When using 'make tinyconfig' to generate the default kconfig, MODULE is
unset.

There are different ways to fix this warning. Here I tried to minimised
the number of modified lines and not add more #ifdef. We could also move
the declaration of the 'mod' variable inside the if-statement or
directly use site_mod->mod.

Fixes: 698bacefe993 ("static_call: Align static_call_is_init() patching condition")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210326105023.2058860-1-matthieu.baerts@tessares.net
---
 kernel/static_call.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 2c5950b..723fcc9 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
 		stop = __stop_static_call_sites;
 
-#ifdef CONFIG_MODULES
 		if (mod) {
+#ifdef CONFIG_MODULES
 			stop = mod->static_call_sites +
 			       mod->num_static_call_sites;
 			init = mod->state == MODULE_STATE_COMING;
-		}
 #endif
+		}
 
 		for (site = site_mod->sites;
 		     site < stop && static_call_key(site) == key; site++) {

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

end of thread, other threads:[~2021-04-09 11:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 10:50 [PATCH mptcp-next] static_call: fix unused variable warn w/o MODULE Matthieu Baerts
2021-03-26 11:12 ` Peter Zijlstra
2021-04-09 11:30 ` [tip: locking/core] static_call: Fix " tip-bot2 for Matthieu Baerts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.