lkml.org 
[lkml]   [2022]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@wanadoo.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 |
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-05-18 14:01    [W:0.069 / U:1.924 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site