LKML Archive on
help / color / mirror / Atom feed
From: Miguel Ojeda <>
To: Linus Torvalds <>
Cc: Steven Rostedt <>,
	Ingo Molnar <>,
	Linux List Kernel Mailing <>
Subject: Re: [PATCH] tracing: silence GCC 9 array bounds warning
Date: Fri, 17 May 2019 21:09:21 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Fri, May 17, 2019 at 7:59 PM Linus Torvalds
<> wrote:
> On Fri, May 17, 2019 at 2:25 AM Miguel Ojeda
> <> wrote:
> >
> > +       memset((char *)(iter) + offsetof(struct trace_iterator, seq), 0,
> > +              sizeof(struct trace_iterator) -
> > +              offsetof(struct trace_iterator, seq));
> Honestly, the above is nasty.
> Whenever you have to split an expression or statement over several
> lines, you should ask yourself why it's so complicated.

Will do -- I was trying to keep the code as closely to the original as
possible (I simply replaced the &iter.seq expression :-)

By the way, how do you all feel about moving this as a generic
facility to zero out the suffix/prefix of an structure? In particular,
since we won't have the LAT* stuff according to Steven.

> Also, the while 'offset' is a variable, any compiler will immediately
> see that it's a constant value, so it's not like this will affect the
> generated code at all.

I like C++'s constexpr (for variable defs), maybe one day we will get
it on C; it is useful to cleanly annotate compile-time values like

> Unless you compile with something crazy like
> '-O0', which is not a supported configuration exactly because we
> expect compilers to not be terminally stupid.

Fun fact: it seems clang folds some of these even under -O0. In
godbolt I see it folding the third argument completely. The first one
isn't, but it is computed on the function prologue, leaving the
'offset' variable unused.


  reply	other threads:[~2019-05-17 19:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17  9:25 Miguel Ojeda
2019-05-17 16:47 ` Steven Rostedt
2019-05-17 18:45   ` Miguel Ojeda
2019-05-17 17:59 ` Linus Torvalds
2019-05-17 19:09   ` Miguel Ojeda [this message]
2019-05-19 21:35     ` Steven Rostedt
2019-05-17 20:54 ` Miguel Ojeda
2019-05-23 12:45 Miguel Ojeda
2019-05-24  2:12 ` Steven Rostedt
2019-05-24  4:05   ` Miguel Ojeda
2019-05-24 11:52     ` 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:

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

  git send-email \
    --in-reply-to='' \ \ \ \ \ \
    --subject='Re: [PATCH] tracing: silence GCC 9 array bounds warning' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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