Re: [PATCH] tracing: silence GCC 9 array bounds warning
From: Miguel Ojeda
Date: Fri May 17 2019 - 14:47:29 EST
Hi Steven,
On Fri, May 17, 2019 at 6:47 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> Hi Miguel,
>
> Linus mentioned this too.
>
> https://lore.kernel.org/lkml/CAHk-=wihYB8w__YQjgYjYZsVniu5CtkTcFycmCGdqVg8GUje7g@xxxxxxxxxxxxxx/T/#u
Ah, I didn't see that. We were discussing here [1] backporting to 4.19
some cleanups we did for GCC 9 a few months ago, so I was testing that
Linus' master was still clean a few hours ago. When I found that
couple of warnings I quickly made a patch before I forgot. I should
probably have added RFC :-)
[1] https://lore.kernel.org/lkml/CANiq72=fsL5m2_e+bNovFCHy3=YVf53EKGtGE_sWvsAD=ONHuQ@xxxxxxxxxxxxxx/
> Setting the LAT_FMT isn't something a function called "reset" should do.
I added the surrounding code heuristically since it was in a single
block with the comment above and since it was repeated in both places,
but I had no idea on the semantics. :-)
> > + memset((char *)(iter) + offsetof(struct trace_iterator,
>
> Why (char *)? Please use (void *).
We are adding a byte-sized offset, so char * is the one that makes
sense. Doing it with void * works, although it is a GNU extension. But
as you prefer :-)
Cheers,
Miguel