linux-stable/drivers/net/can/spi
Vincent Mailhol 1a6dd99966 can: mcp251xfd: silence clang's -Wunaligned-access warning
clang emits a -Wunaligned-access warning on union
mcp251xfd_tx_ojb_load_buf.

The reason is that field hw_tx_obj (not declared as packed) is being
packed right after a 16 bits field inside a packed struct:

| union mcp251xfd_tx_obj_load_buf {
| 	struct __packed {
| 		struct mcp251xfd_buf_cmd cmd;
| 		  /* ^ 16 bits fields */
| 		struct mcp251xfd_hw_tx_obj_raw hw_tx_obj;
| 		  /* ^ not declared as packed */
| 	} nocrc;
| 	struct __packed {
| 		struct mcp251xfd_buf_cmd_crc cmd;
| 		struct mcp251xfd_hw_tx_obj_raw hw_tx_obj;
| 		__be16 crc;
| 	} crc;
| } ____cacheline_aligned;

Starting from LLVM 14, having an unpacked struct nested in a packed
struct triggers a warning. c.f. [1].

This is a false positive because the field is always being accessed
with the relevant put_unaligned_*() function. Adding __packed to the
structure declaration silences the warning.

[1] https://github.com/llvm/llvm-project/issues/55520

Link: https://lore.kernel.org/all/20220518114357.55452-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-05-19 22:15:51 +02:00
..
mcp251xfd can: mcp251xfd: silence clang's -Wunaligned-access warning 2022-05-19 22:15:51 +02:00
hi311x.c can: can-dev: remove obsolete CAN LED support 2022-05-19 22:15:51 +02:00
Kconfig can: mcp251xfd: rename driver files and subdir to mcp251xfd 2020-09-30 21:54:30 +02:00
Makefile can: mcp251xfd: rename driver files and subdir to mcp251xfd 2020-09-30 21:54:30 +02:00
mcp251x.c can: can-dev: remove obsolete CAN LED support 2022-05-19 22:15:51 +02:00