All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Jiri Slaby <jirislaby@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 06:33:16 +0100	[thread overview]
Message-ID: <2025020501-doily-sandlot-8434@gregkh> (raw)
In-Reply-To: <Z6L1XwE-WEzcGFwv@kspp>

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

  reply	other threads:[~2025-02-05  5:33 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 [this message]
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
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=2025020501-doily-sandlot-8434@gregkh \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.