linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org, linux-can@vger.kernel.org
Subject: Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning
Date: Wed, 18 May 2022 13:58:20 +0200	[thread overview]
Message-ID: <20220518115820.qzvyrnwsb4wvayq2@pengutronix.de> (raw)
In-Reply-To: <20220518114357.55452-1-mailhol.vincent@wanadoo.fr>

[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-05-18 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  6:45 drivers/net/can/spi/mcp251xfd/mcp251xfd.h:481:34: warning: field hw_tx_obj within 'struct mcp251xfd_tx_obj_load_buf::(unnamed at drivers/net/can/spi/mcp251xfd/mcp251xfd.h:479:2)' is less aligned than 'struct mcp251xfd_hw_tx_obj_raw' and is usually due to kernel test robot
2022-05-18  7:05 ` Marc Kleine-Budde
2022-05-18 11:43   ` [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning Vincent Mailhol
2022-05-18 11:58     ` Marc Kleine-Budde [this message]
2022-05-18 16:05     ` Nathan Chancellor
2022-05-18 16:15       ` Vincent MAILHOL
2022-05-18 16:18         ` Nathan Chancellor
2022-05-18 20:15           ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220518115820.qzvyrnwsb4wvayq2@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=mailhol.vincent@wanadoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).