mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Borislav Petkov <bp@suse.de>
Cc: Xie XiuQi <xiexiuqi@huawei.com>,
	akpm@linux-foundation.org, n-horiguchi@ah.jp.nec.com,
	gong.chen@linux.intel.com, bhelgaas@google.com,
	tony.luck@intel.com, linux-kernel@vger.kernel.org,
	jingle.chen@huawei.com
Subject: Re: [PATCH] trace, RAS: remove unnecessary const
Date: Thu, 19 Mar 2015 08:57:56 -0400	[thread overview]
Message-ID: <20150319085756.2c649e7d@gandalf.local.home> (raw)
In-Reply-To: <20150319103330.GC11544@pd.tnic>

On Thu, 19 Mar 2015 11:33:30 +0100
Borislav Petkov <bp@suse.de> wrote:

> On Thu, Mar 19, 2015 at 04:50:04PM +0800, Xie XiuQi wrote:
> > These parameters are passed by value. There's no need to make them const.
> 
> I can think of a reason:
> 
> include/trace/../../include/ras/ras_event.h: In function ‘ftrace_raw_event_mc_event’:
> include/trace/../../include/ras/ras_event.h:136:35: error: assignment of read-only parameter ‘top_layer’
>    __entry->top_layer  = top_layer = 12;
>                                    ^
> ---
> diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
> index 79abb9c71772..e4721eac3e25 100644
> --- a/include/ras/ras_event.h
> +++ b/include/ras/ras_event.h
> @@ -133,7 +133,7 @@ TRACE_EVENT(mc_event,
>                 __assign_str(label, label);
>                 __entry->error_count            = error_count;
>                 __entry->mc_index               = mc_index;
> -               __entry->top_layer              = top_layer;
> +               __entry->top_layer              = top_layer = 12;
>                 __entry->middle_layer           = mid_layer;
>                 __entry->lower_layer            = low_layer;
>                 __entry->address                = address;
> ---
> 
> I'm not saying it is a particularly sane reason and no one would even
> *think* of changing TP parameters passed on from higher layers in the TP
> itself but I've seen people do lotsa crazy things - things they normally
> would never do - so if it doesn't hurt having the const here, what's the
> downside of having the compiler do that sanity checking for us too?

That's a bit of a stretch. But sure, there's no real downside to having
it, except that it makes one take a double take when seeing it, and
thinking about why it would even be needed (like I did).

> 
> Steve, this is an invitation for your crazy fantasy! :-P
> 

I think you had the crazy fantasy with the above patch!


-- Steve

  parent reply	other threads:[~2015-03-19 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19  8:50 Xie XiuQi
2015-03-19 10:33 ` Borislav Petkov
2015-03-19 11:57   ` Xie XiuQi
2015-03-19 13:00     ` Steven Rostedt
2015-03-20  4:05       ` Xie XiuQi
2015-03-19 12:57   ` Steven Rostedt [this message]
2015-03-19 13:10     ` Borislav Petkov

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=20150319085756.2c649e7d@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=bp@suse.de \
    --cc=gong.chen@linux.intel.com \
    --cc=jingle.chen@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=tony.luck@intel.com \
    --cc=xiexiuqi@huawei.com \
    /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

Powered by JetHome