Re: [greybus-dev] [PATCH] greybus: uart: fix uninitialized flow control variable

From: Johan Hovold
Date: Thu May 14 2020 - 03:04:53 EST


On Wed, Apr 29, 2020 at 03:00:44PM -0500, Alex Elder wrote:
> On 4/29/20 2:00 PM, Arnd Bergmann wrote:
> > gcc-10 points out an uninitialized variable use:
>
> Wow, nice, checking individual uninitialized fields within
> the structure.
>
> The structure should really be zero-initialized anyway; it's
> passed as a structure in a message elsewhere. With your
> change, all fields in the structure are written, but in
> theory the structure could change and stack garbage could
> be sent over the wire.
>
> What do you think of doing this instead? Or in addition?
>
> struct gb_tty_line_coding newline = { };
>
> (Presumably that would also silence the warning.)
>
> I endorse of your change, either way.

Looks like Greg ended up applying an identical version of this patch
that was submitted this week instead.

Taking a closer look at this code I noticed we have two versions of this
line-coding struct which are supposed by be identical, but which could
get out of sync (and have once already it turns out).

Johan