Re: [PATCH][next] tty: tty_buffer: Avoid hundreds of -Wflex-array-member-not-at-end warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux