mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Rakib Mullick <rakib.mullick@gmail.com>
Cc: hpa@zytor.com, Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] x86, ftrace: Fix compiler warning in ftrace.c
Date: Tue, 17 May 2011 12:04:01 -0400	[thread overview]
Message-ID: <1305648241.5456.743.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1305221620.7986.4.camel@localhost.localdomain>

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();
> 



  reply	other threads:[~2011-05-17 16:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 17:33 Rakib Mullick
2011-05-17 16:04 ` Steven Rostedt [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305648241.5456.743.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rakib.mullick@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®