Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning

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

 



On 18.05.2022 20:43:57, Vincent Mailhol wrote:
> 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
> 
> Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>

Thank! Applies to linux-can-next/testing.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux