[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220518115820.qzvyrnwsb4wvayq2@pengutronix.de>
Date: Wed, 18 May 2022 13:58:20 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Vincent Mailhol <mailhol.vincent@...adoo.fr>
Cc: kernel test robot <lkp@...el.com>, llvm@...ts.linux.dev,
kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
linux-can@...r.kernel.org
Subject: Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access
warning
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@...adoo.fr>
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 |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists