All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] static_call: fix function type mismatch
@ 2021-03-22 17:06 Arnd Bergmann
  2021-03-22 19:32 ` Steven Rostedt
  0 siblings, 1 reply; 20+ messages in thread
From: Arnd Bergmann @ 2021-03-22 17:06 UTC (permalink / raw)
  To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Ingo Molnar,
	Juri Lelli, Vincent Guittot
  Cc: Arnd Bergmann, Steven Rostedt, Ard Biesheuvel, Dietmar Eggemann,
	Ben Segall, Mel Gorman, Daniel Bristot de Oliveira,
	Frederic Weisbecker, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The __static_call_return0() function is declared to return a 'long',
while it aliases a couple of functions that all return 'int'. When
building with 'make W=1', gcc warns about this:

kernel/sched/core.c:5420:37: error: cast between incompatible function types from 'long int (*)(void)' to 'int (*)(void)' [-Werror=cast-function-type]
 5420 |   static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);

Change the function to return 'int' as well, but remove the cast to
ensure we get a warning if any of the types ever change.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/static_call.h | 6 +++---
 kernel/sched/core.c         | 6 +++---
 kernel/static_call.c        | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 85ecc789f4ff..3fc2975906ad 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -148,7 +148,7 @@ extern void __static_call_update(struct static_call_key *key, void *tramp, void
 extern int static_call_mod_init(struct module *mod);
 extern int static_call_text_reserved(void *start, void *end);
 
-extern long __static_call_return0(void);
+extern int __static_call_return0(void);
 
 #define __DEFINE_STATIC_CALL(name, _func, _func_init)			\
 	DECLARE_STATIC_CALL(name, _func);				\
@@ -221,7 +221,7 @@ static inline int static_call_text_reserved(void *start, void *end)
 	return 0;
 }
 
-static inline long __static_call_return0(void)
+static inline int __static_call_return0(void)
 {
 	return 0;
 }
@@ -247,7 +247,7 @@ struct static_call_key {
 	void *func;
 };
 
-static inline long __static_call_return0(void)
+static inline int __static_call_return0(void)
 {
 	return 0;
 }
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3a36f0b0742e..d22c609b9484 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5399,7 +5399,7 @@ static void sched_dynamic_update(int mode)
 	switch (mode) {
 	case preempt_dynamic_none:
 		static_call_update(cond_resched, __cond_resched);
-		static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);
+		static_call_update(might_resched, __static_call_return0);
 		static_call_update(preempt_schedule, (typeof(&preempt_schedule)) NULL);
 		static_call_update(preempt_schedule_notrace, (typeof(&preempt_schedule_notrace)) NULL);
 		static_call_update(irqentry_exit_cond_resched, (typeof(&irqentry_exit_cond_resched)) NULL);
@@ -5416,8 +5416,8 @@ static void sched_dynamic_update(int mode)
 		break;
 
 	case preempt_dynamic_full:
-		static_call_update(cond_resched, (typeof(&__cond_resched)) __static_call_return0);
-		static_call_update(might_resched, (typeof(&__cond_resched)) __static_call_return0);
+		static_call_update(cond_resched, __static_call_return0);
+		static_call_update(might_resched, __static_call_return0);
 		static_call_update(preempt_schedule, __preempt_schedule_func);
 		static_call_update(preempt_schedule_notrace, __preempt_schedule_notrace_func);
 		static_call_update(irqentry_exit_cond_resched, irqentry_exit_cond_resched);
diff --git a/kernel/static_call.c b/kernel/static_call.c
index 6906c6ec4c97..11aa4bcee315 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -489,7 +489,7 @@ int __init static_call_init(void)
 }
 early_initcall(static_call_init);
 
-long __static_call_return0(void)
+int __static_call_return0(void)
 {
 	return 0;
 }
-- 
2.29.2


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

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

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 17:06 [PATCH] static_call: fix function type mismatch Arnd Bergmann
2021-03-22 19:32 ` Steven Rostedt
2021-03-22 20:47   ` Peter Zijlstra
2021-03-22 21:18     ` Arnd Bergmann
2021-03-22 21:29       ` Steven Rostedt
2021-03-23  7:47         ` Peter Zijlstra
2021-03-24 12:46           ` Rasmus Villemoes
2021-03-24 16:01             ` Sami Tolvanen
2021-03-24 16:45               ` Rasmus Villemoes
2021-03-24 17:33                 ` Peter Zijlstra
2021-03-24 19:16                   ` Peter Zijlstra
2021-03-24 21:51                   ` Rasmus Villemoes
2021-03-24 22:34                     ` Sami Tolvanen
2021-03-24 22:53                       ` Rasmus Villemoes
2021-03-24 23:40                         ` Sami Tolvanen
2021-03-25  0:42                           ` Rasmus Villemoes
2021-03-25  7:42                             ` Peter Zijlstra
2021-03-25  7:45                               ` Ard Biesheuvel
2021-03-25  8:27                               ` Rasmus Villemoes
2021-03-23  7:35       ` Peter Zijlstra

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.