Linux Serial subsystem development
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Jiri Slaby <jirislaby@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: 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 18:33:13 +1030	[thread overview]
Message-ID: <8fa0b596-c812-4bc5-bdc1-beb75d7928d3@embeddedor.com> (raw)
In-Reply-To: <44d7feed-173e-4e46-994b-e3136161efc9@kernel.org>



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;
+};
+


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

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

However, I'm okay with whatever you guys prefer, just let me
know.

Thanks
-Gustavo

  reply	other threads:[~2025-02-05  8:03 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 [this message]
2025-02-05  8:16         ` Greg Kroah-Hartman
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=8fa0b596-c812-4bc5-bdc1-beb75d7928d3@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=gregkh@linuxfoundation.org \
    --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