Skip to contentSkip to conversation

nds32: ftrace: fix pointer comparison warning

PATCH In review Randy Dunlap 2 participants 3 messages Oct 27, 2021 ftrace

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nds32: ftrace: fix pointer comparison warning

GCC 11.1.0 for nds32 (nds32le if it matters) complains:

../arch/nds32/kernel/ftrace.c: In function '_mcount':
../arch/nds32/kernel/ftrace.c:24:35: error: comparison of distinct pointer types lacks a cast [-Werror]
24 | if (ftrace_trace_function != ftrace_stub)
| ^~

Cast the second function (pointer) to (void *) to avoid the warning.

Fixes a18082575c66 ("nds32/ftrace: Support static function tracer")

To: Greentime Hu <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Zong Li <[email protected]>
Cc: Nick Hu <[email protected]>
Cc: Vincent Chen <[email protected]>

---
 arch/nds32/kernel/ftrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/nds32/kernel/ftrace.c +1 -1
@@ -21,7 +21,7 @@ noinline void _mcount(unsigned long pare
 
 	unsigned long ip = (unsigned long)__builtin_return_address(0);
 
-	if (ftrace_trace_function != ftrace_stub)
+	if (ftrace_trace_function != (void *)ftrace_stub)
 		ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip,
 				      NULL, NULL);
 
maintainer
#1 lore raw
Quoted 25 lines · On Tue, 26 Oct 2021 22:55:54 -0700 Randy Dunlap <[email protected]> wrote:

GCC 11.1.0 for nds32 (nds32le if it matters) complains:

../arch/nds32/kernel/ftrace.c: In function '_mcount':
../arch/nds32/kernel/ftrace.c:24:35: error: comparison of distinct pointer types lacks a cast [-Werror]
24 | if (ftrace_trace_function != ftrace_stub)
| ^~

Cast the second function (pointer) to (void *) to avoid the warning.

Fixes a18082575c66 ("nds32/ftrace: Support static function tracer")

To: Greentime Hu <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Zong Li <[email protected]>
Cc: Nick Hu <[email protected]>
Cc: Vincent Chen <[email protected]>

---
 arch/nds32/kernel/ftrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

arch/nds32/kernel/ftrace.c noinline void _mcount(unsigned long pare · line 27

Quoted 8 lines
arch/nds32/kernel/ftrace.c +1 -1
@@ -21,7 +21,7 @@ noinline void _mcount(unsigned long pare
 
 	unsigned long ip = (unsigned long)__builtin_return_address(0);
 
-	if (ftrace_trace_function != ftrace_stub)
+	if (ftrace_trace_function != (void *)ftrace_stub)
 		ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip,
 				      NULL, NULL);
 

Or update ftrace_trace_function prototype that was missed when ftrace_stub prototype was updated.

---

arch/nds32/kernel/ftrace.c +1 -1
index f0ef4842d191..711bc8cd186d 100644
@@ -6,7 +6,7 @@
 
 #ifndef CONFIG_DYNAMIC_FTRACE
 extern void (*ftrace_trace_function)(unsigned long, unsigned long,
-				     struct ftrace_ops*, struct pt_regs*);
+				     struct ftrace_ops*, struct ftrace_regs*);
 extern void ftrace_graph_caller(void);
 
 noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
#2 lore raw
Quoted 48 lines · Steven Rostedt
Quoted 25 lines · On Tue, 26 Oct 2021 22:55:54 -0700 Randy Dunlap <[email protected]> wrote:

GCC 11.1.0 for nds32 (nds32le if it matters) complains:

../arch/nds32/kernel/ftrace.c: In function '_mcount':
../arch/nds32/kernel/ftrace.c:24:35: error: comparison of distinct pointer types lacks a cast [-Werror]

    24 |         if (ftrace_trace_function != ftrace_stub)
       |                                   ^~

Cast the second function (pointer) to (void *) to avoid the warning.

Fixes a18082575c66 ("nds32/ftrace: Support static function tracer")

To: Greentime Hu <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Zong Li <[email protected]>
Cc: Nick Hu <[email protected]>
Cc: Vincent Chen <[email protected]>

---
  arch/nds32/kernel/ftrace.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

arch/nds32/kernel/ftrace.c noinline void _mcount(unsigned long pare · line 27

Quoted 8 lines
arch/nds32/kernel/ftrace.c +1 -1
@@ -21,7 +21,7 @@ noinline void _mcount(unsigned long pare
 
  	unsigned long ip = (unsigned long)__builtin_return_address(0);
 
-	if (ftrace_trace_function != ftrace_stub)
+	if (ftrace_trace_function != (void *)ftrace_stub)
  		ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip,
  				      NULL, NULL);
 

Or update ftrace_trace_function prototype that was missed when ftrace_stub prototype was updated.

---

arch/nds32/kernel/ftrace.c +0 -0
index f0ef4842d191..711bc8cd186d 100644

arch/nds32/kernel/ftrace.c line 12

Quoted 8 lines
arch/nds32/kernel/ftrace.c +1 -1
@@ -6,7 +6,7 @@
 
  #ifndef CONFIG_DYNAMIC_FTRACE
  extern void (*ftrace_trace_function)(unsigned long, unsigned long,
-				     struct ftrace_ops*, struct pt_regs*);
+				     struct ftrace_ops*, struct ftrace_regs*);
  extern void ftrace_graph_caller(void);
 
  noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,

OK, looks good.

Thanks.

Signature · 1 line
~Randy