Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: tty_buffer: switch data type to u8

There is no reason to have tty_buffer::data typed as unsigned long.
Switch to u8, but preserve the ulong alignment using __aligned.

This allows for the cast removal from char_buf_ptr(). And for use of
struct_size() in the allocation in tty_buffer_alloc() -- in the next
patch.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230816105530.3335-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
d4d13ff3 2f492672

+2 -2
+2 -2
include/linux/tty_buffer.h
··· 19 19 unsigned int read; 20 20 bool flags; 21 21 /* Data points here */ 22 - unsigned long data[]; 22 + u8 data[] __aligned(sizeof(unsigned long)); 23 23 }; 24 24 25 25 static inline u8 *char_buf_ptr(struct tty_buffer *b, unsigned int ofs) 26 26 { 27 - return ((u8 *)b->data) + ofs; 27 + return b->data + ofs; 28 28 } 29 29 30 30 static inline u8 *flag_buf_ptr(struct tty_buffer *b, unsigned int ofs)