[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025020501-doily-sandlot-8434@gregkh>
Date: Wed, 5 Feb 2025 06:33:16 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: Jiri Slaby <jirislaby@...nel.org>, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] tty: tty_buffer: Avoid hundreds of
-Wflex-array-member-not-at-end warnings
On Wed, Feb 05, 2025 at 03:51:35PM +1030, Gustavo A. R. Silva wrote:
> --- a/include/linux/tty_buffer.h
> +++ b/include/linux/tty_buffer.h
> @@ -8,19 +8,24 @@
> #include <linux/workqueue.h>
>
> 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;
> + /* New members MUST be added within the struct_group() macro below. */
Why? You need to say that here otherwise we aren't going to know.
> + struct_group_tagged(tty_buffer_hdr, __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;
> + );
> /* Data points here */
> u8 data[] __aligned(sizeof(unsigned long));
> };
> +static_assert(offsetof(struct tty_buffer, data) == sizeof(struct tty_buffer_hdr),
> + "struct member likely outside of struct_group_tagged()");
>
> static inline u8 *char_buf_ptr(struct tty_buffer *b, unsigned int ofs)
> {
> @@ -33,15 +38,15 @@ static inline u8 *flag_buf_ptr(struct tty_buffer *b, unsigned int ofs)
> }
>
> struct tty_bufhead {
> - struct tty_buffer *head; /* Queue head */
> - struct work_struct work;
> - struct mutex lock;
> - atomic_t priority;
> - struct tty_buffer sentinel;
> - struct llist_head free; /* Free queue head */
> - atomic_t mem_used; /* In-use buffers excluding free list */
> - int mem_limit;
> - struct tty_buffer *tail; /* Active buffer */
> + struct tty_buffer *head; /* Queue head */
> + struct work_struct work;
> + struct mutex lock;
> + atomic_t priority;
> + struct tty_buffer_hdr sentinel;
> + struct llist_head free; /* Free queue head */
> + atomic_t mem_used; /* In-use buffers excluding free list */
> + int mem_limit;
> + struct tty_buffer *tail; /* Active buffer */
> };
Did you change anything in this structure? By reformatting it, it's
hard to tell what happened, so please don't do that :(
thanks,
greg k-h
Powered by blists - more mailing lists