linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86, ftrace: Fix compiler warning in ftrace.c
@ 2011-05-12 17:33 Rakib Mullick
  2011-05-17 16:04 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Rakib Mullick @ 2011-05-12 17:33 UTC (permalink / raw)
  To: Ingo, Molnar
  Cc: hpa, Thomas Gleixner, linux-kernel, x86, Steven Rostedt,
	Frederic Weisbecker

 Due to commit dc326fca2b64 (x86, cpu: Clean up and unify the NOP selection infrastructure), we get the following warning:

arch/x86/kernel/ftrace.c: In function ‘ftrace_make_nop’:
arch/x86/kernel/ftrace.c:308:6: warning: assignment discards qualifiers from pointer target type
arch/x86/kernel/ftrace.c: In function ‘ftrace_make_call’:
arch/x86/kernel/ftrace.c:318:6: warning: assignment discards qualifiers from pointer target type
 
ftrace_nop_replace() now returns const unsigned char *, so change its associated function/variable to its compatible type to keep compiler clam.


Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
---

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 0ba15a6..d2d82cf 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -266,8 +266,8 @@ static const unsigned char *ftrace_nop_replace(void)
 }
 
 static int
-ftrace_modify_code(unsigned long ip, unsigned char *old_code,
-		   unsigned char *new_code)
+ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
+		   unsigned const char *new_code)
 {
 	unsigned char replaced[MCOUNT_INSN_SIZE];
 
@@ -290,7 +290,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
 		return -EINVAL;
 
 	/* replace the text with the new text */
-	if (do_ftrace_mod_code(ip, new_code))
+	if (do_ftrace_mod_code(ip, (void *)new_code))
 		return -EPERM;
 
 	sync_core();
@@ -301,7 +301,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
 int ftrace_make_nop(struct module *mod,
 		    struct dyn_ftrace *rec, unsigned long addr)
 {
-	unsigned char *new, *old;
+	unsigned const char *new, *old;
 	unsigned long ip = rec->ip;
 
 	old = ftrace_call_replace(ip, addr);
@@ -312,7 +312,7 @@ int ftrace_make_nop(struct module *mod,
 
 int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 {
-	unsigned char *new, *old;
+	unsigned const char *new, *old;
 	unsigned long ip = rec->ip;
 
 	old = ftrace_nop_replace();



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

* Re: [PATCH] x86, ftrace: Fix compiler warning in ftrace.c
  2011-05-12 17:33 [PATCH] x86, ftrace: Fix compiler warning in ftrace.c Rakib Mullick
@ 2011-05-17 16:04 ` Steven Rostedt
       [not found]   ` <BANLkTim2rcr9F=5+C9t-BU8OVfbWw5mFyQ@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2011-05-17 16:04 UTC (permalink / raw)
  To: Rakib Mullick
  Cc: hpa, Thomas Gleixner, linux-kernel, x86, Frederic Weisbecker

On Thu, 2011-05-12 at 23:33 +0600, Rakib Mullick wrote:
> Due to commit dc326fca2b64 (x86, cpu: Clean up and unify the NOP selection infrastructure), we get the following warning:
> 
> arch/x86/kernel/ftrace.c: In function ‘ftrace_make_nop’:
> arch/x86/kernel/ftrace.c:308:6: warning: assignment discards qualifiers from pointer target type
> arch/x86/kernel/ftrace.c: In function ‘ftrace_make_call’:
> arch/x86/kernel/ftrace.c:318:6: warning: assignment discards qualifiers from pointer target type
>  
> ftrace_nop_replace() now returns const unsigned char *, so change its associated function/variable to its compatible type to keep compiler clam.
> 
> 
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
> ---
> 
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 0ba15a6..d2d82cf 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -266,8 +266,8 @@ static const unsigned char *ftrace_nop_replace(void)
>  }
>  
>  static int
> -ftrace_modify_code(unsigned long ip, unsigned char *old_code,
> -		   unsigned char *new_code)
> +ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
> +		   unsigned const char *new_code)
>  {
>  	unsigned char replaced[MCOUNT_INSN_SIZE];
>  
> @@ -290,7 +290,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
>  		return -EINVAL;
>  
>  	/* replace the text with the new text */
> -	if (do_ftrace_mod_code(ip, new_code))
> +	if (do_ftrace_mod_code(ip, (void *)new_code))

Instead of typecasting, why not make new_code const void *?

This would probably trickle down to change __probe_kernel_write() which
would not be a bad thing.

-- Steve

>  		return -EPERM;
>  
>  	sync_core();
> @@ -301,7 +301,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
>  int ftrace_make_nop(struct module *mod,
>  		    struct dyn_ftrace *rec, unsigned long addr)
>  {
> -	unsigned char *new, *old;
> +	unsigned const char *new, *old;
>  	unsigned long ip = rec->ip;
>  
>  	old = ftrace_call_replace(ip, addr);
> @@ -312,7 +312,7 @@ int ftrace_make_nop(struct module *mod,
>  
>  int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>  {
> -	unsigned char *new, *old;
> +	unsigned const char *new, *old;
>  	unsigned long ip = rec->ip;
>  
>  	old = ftrace_nop_replace();
> 



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

* Re: [PATCH] x86, ftrace: Fix compiler warning in ftrace.c
       [not found]   ` <BANLkTim2rcr9F=5+C9t-BU8OVfbWw5mFyQ@mail.gmail.com>
@ 2011-05-17 17:45     ` Steven Rostedt
       [not found]       ` <BANLkTinUCh_ZbfxEtC4XYOqN_q6_yBq92Q@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2011-05-17 17:45 UTC (permalink / raw)
  To: Rakib Mullick
  Cc: hpa, Thomas Gleixner, linux-kernel, x86, Frederic Weisbecker

On Tue, 2011-05-17 at 23:11 +0600, Rakib Mullick wrote:
> 
BTW, You have a weird email client. Causes lots of weird whitespace

> There are other places where they depend on __probe_kernel_write(), it
> might require to change all __probe_kernel_write() callers.

Why would callers of __probe_kernel_write() need to be changed? You can
pass any pointer into a const void*. You just can't do it the other way
around.

-- Steve

>         
> 



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

* Re: [PATCH] x86, ftrace: Fix compiler warning in ftrace.c
       [not found]       ` <BANLkTinUCh_ZbfxEtC4XYOqN_q6_yBq92Q@mail.gmail.com>
@ 2011-05-18 13:30         ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2011-05-18 13:30 UTC (permalink / raw)
  To: Rakib Mullick
  Cc: hpa, Thomas Gleixner, linux-kernel, x86, Frederic Weisbecker

On Wed, 2011-05-18 at 11:02 +0600, Rakib Mullick wrote:
> 

>         
> Cause, __probe_kernel_write() currently takes void * as its parameter.
> That means all the users of __probe_kernel_write() currently passes
> void *. If we change __probe_kernel_write's parameter ( src) from void
> * to const void * , then all the callers also needs to do that. Isn't
> it?

No.

Look at __probe_kernel_write() itself. It calls
__copy_to_user_in_atomic() which takes const void *src, where we pass in
void *src. That __probe_kernel_write() having void *src is actually a
bug.

Make that a separate patch, or maybe I'll just do it.

-- Steve




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

end of thread, other threads:[~2011-05-18 13:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 17:33 [PATCH] x86, ftrace: Fix compiler warning in ftrace.c Rakib Mullick
2011-05-17 16:04 ` Steven Rostedt
     [not found]   ` <BANLkTim2rcr9F=5+C9t-BU8OVfbWw5mFyQ@mail.gmail.com>
2011-05-17 17:45     ` Steven Rostedt
     [not found]       ` <BANLkTinUCh_ZbfxEtC4XYOqN_q6_yBq92Q@mail.gmail.com>
2011-05-18 13:30         ` Steven Rostedt

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).