Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] tty: tty_buffer: Avoid hundreds of -Wflex-array-member-not-at-end warnings
Date: Wed, 5 Feb 2025 09:16:45 +0100	[thread overview]
Message-ID: <2025020513-arena-tackling-1741@gregkh> (raw)
In-Reply-To: <8fa0b596-c812-4bc5-bdc1-beb75d7928d3@embeddedor.com>

On Wed, Feb 05, 2025 at 06:33:13PM +1030, Gustavo A. R. Silva wrote:
> 
> 
> On 05/02/25 17:29, Jiri Slaby wrote:
> > On 05. 02. 25, 7:49, Gustavo A. R. Silva wrote:
> > > If the above changes are better for you then I'll send a new patch. :)
> > 
> > No, you are supposed to switch tty_buffer to tty_buffer_hdr too.
> 
> Do you mean something like the following:
> 
>  struct tty_buffer {
> -       union {
> -               struct tty_buffer *next;
> -               struct llist_node free;
> -       };
> -       unsigned int used;
> -       unsigned int size;
> -       unsigned int commit;
> -       unsigned int lookahead;         /* Lazy update on recv, can become less than "read" */
> -       unsigned int read;
> -       bool flags;
> +       struct tty_buffer_hdr hdr;
>         /* Data points here */
>         u8 data[] __aligned(sizeof(unsigned long));
>  };
> 
> +struct tty_buffer_hdr {
> +        union {
> +                struct tty_buffer *next;
> +                struct llist_node free;
> +        };
> +        unsigned int used;
> +        unsigned int size;
> +        unsigned int commit;
> +        unsigned int lookahead; /* Lazy update on recv, can become less than "read" */
> +        unsigned int read;
> +        bool flags;
> +};
> +

Yes!

> The problem with this is that then we have to modify a lot of
> lines from, let's say, instance->used, instance->size, etc...
> to instance->hdr.used, instance->hdr.size, and so on...

Great, let's do that and get it right please.

> This code churn is avoided if we use the struct_group() helper.

It's not "churn" if it is "fix the code to be correct" :)

thanks,

greg k-h

  reply	other threads:[~2025-02-05  8:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05  5:21 [PATCH][next] tty: tty_buffer: Avoid hundreds of -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-05  5:33 ` Greg Kroah-Hartman
2025-02-05  5:36 ` Greg Kroah-Hartman
2025-02-05  6:45   ` Jiri Slaby
2025-02-05  6:49   ` Gustavo A. R. Silva
2025-02-05  6:59     ` Jiri Slaby
2025-02-05  8:03       ` Gustavo A. R. Silva
2025-02-05  8:16         ` Greg Kroah-Hartman [this message]
2025-02-05  8:25           ` Gustavo A. R. Silva

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=2025020513-arena-tackling-1741@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /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