Re: [PATCH] tracing: silence GCC 9 array bounds warning

From: Steven Rostedt
Date: Thu May 23 2019 - 22:15:10 EST


On Thu, 23 May 2019 14:45:35 +0200
Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote:

> +/*
> + * Reset the state of the trace_iterator so that it can read consumed data.
> + * Normally, the trace_iterator is used for reading the data when it is not
> + * consumed, and must retain state.
> + */
> +static __always_inline void trace_iterator_reset(struct trace_iterator *iter)
> +{
> + const size_t offset = offsetof(struct trace_iterator, seq);
> +
> + /*
> + * Keep gcc from complaining about overwriting more than just one
> + * member in the structure.
> + */
> + memset((char *)(iter) + offset, 0, sizeof(struct trace_iterator) - offset);

I still prefer the typecast of void *, as that's used a bit more in the
kernel, but since char * is also used (not as much), I'll leave it. But
the parenthesis around iter are unnecessary. I'll remove them.

-- Steve


> +
> + iter->pos = -1;
> +}
> +