Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp621245iob; Wed, 18 May 2022 09:18:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/PYs2AqU24aSgWFcXFZ4CUcgDW3deRkPtwJHeRFXfD/v4jbORz8KmpmovyOv2EVJnkckx X-Received: by 2002:a17:902:b941:b0:14d:af72:3f23 with SMTP id h1-20020a170902b94100b0014daf723f23mr386223pls.6.1652890714683; Wed, 18 May 2022 09:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652890714; cv=none; d=google.com; s=arc-20160816; b=PYFwzc268mNobGB0nfCMzm84FROtYl85CFoIJRQyZIe7SMjRFT1YFHXIYJ+3kJyLy4 tJ6Yz5i9YDfXgFBxPJXxxH+/K6dLw/L17oCZa3/cIo31jDKgctNegDm+Zi8ughIMbGTQ TtwVDyoZxgf6J/9lLIvUAt1TNOTx4k7PYRPOmPQTGZsTKBlo04kny1U3/HI1gtKRHMVz WhQ99TP4smARXEFzwOPMKlYU1XBWBj94Ttbx4HjcT/wsE8bVLvsF9y0R/cSwnDg8lyoU hSIAqOoNGkRM382cOdhG2+MSDz/kICh5LfBCQq5yd/WGYl3uysEmNzOh5u9K5jZXBHgj oHqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Z9UtBROmWBO/qFIJ/AjdgtPzFSrARb7ty02G0iVZT0=; b=eEyfWCC3lilXRn+w2OWgo89T4gf734t0gpE9EaOZDuGJmyWmVI2TvrZYAwwiPxSmai fGDzpcsq6PubSO7DJuWwNLLU0eLc2XIEgtTvFpAMyQdltlXmRH41fq/n+p/+O9g/6WuB nnNDleNvYxMN9+1JZ6aHVY2ojUBGWnBiVNMmKhrfBt5gyOAbDnDOoFsXeq5AMkhkke5m hT1pHc6pjtzNeD/dI78552FPs1eDpFiYqzZVyo3+Bm9URCygnASwKvHf3oHtv6KB6Bhr coupDEFYpeZnl6PAHyoCegzUoF3+obVvmYyr90Vg44d78klYqA1aY3nK4jo/o2MSXH5N hFqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgM0jXwM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v13-20020a65460d000000b003db84c28b34si2990982pgq.147.2022.05.18.09.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 09:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgM0jXwM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2286F1E15E9; Wed, 18 May 2022 09:18:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239894AbiERQSY (ORCPT + 99 others); Wed, 18 May 2022 12:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234867AbiERQSX (ORCPT ); Wed, 18 May 2022 12:18:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13DF1E012E; Wed, 18 May 2022 09:18:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B3E261601; Wed, 18 May 2022 16:18:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AE79C385A5; Wed, 18 May 2022 16:18:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652890701; bh=RgRhuYRHhC4Q30XicZretiBGKHcP4GLPcS0/38yDF4w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CgM0jXwMbLaK4x+YPbr0pbj5EojPWi1+S2LlU/vfvUuik/zWaJBLGYA1+b2oELSi1 jzB39mz9eo7kAjeEbUvLw/VTPbUbSmlHcx0TmNWDYP2wpGC5Ubram57aDFCTsZ9J7y 3oizkHq4Borhvtz258e04Wwum4eRwR5hKCjFKEhvIGYemLqYAaYwb0hfCmX1aOR6FV iGNQ9ESQ24vl/UkjP7V6ML7UjQAMra5+/EZuMBSTyY8l52d5on3ZvNC7R4r2PBues4 8KpmoohBgpRSmhNAGH3CcAS95UqDOycF4PQVQHLN7/vWzIBUCUJ2UxHc/MEq9EB+F6 gJFqa1atrjUiw== Date: Wed, 18 May 2022 09:18:19 -0700 From: Nathan Chancellor To: Vincent MAILHOL Cc: Marc Kleine-Budde , kernel test robot , 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 Message-ID: References: <20220518070517.q53bjzo6lbnq3f2i@pengutronix.de> <20220518114357.55452-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 01:15:04AM +0900, Vincent MAILHOL wrote: > On Tue. 19 May 2022 at 01:08, Nathan Chancellor wrote: > > Hi Vincent, > > > > On Wed, May 18, 2022 at 08:43:57PM +0900, 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 > > > --- > > > Actually, I do not have llvm 14 installed so I am not able to test > > > (this check was introduced in v14). But as explained in [1], adding > > > __packed should fix the warning. > > > > Thanks for the patch! This does resolve the warning (verified with LLVM > > 15). > > Great, thanks for the check! Does this mean we can add you Tested-by > (I assume yes, c.f. below, if not the case, please raise your voice). Sure, see below. > > > Because this is a false positive, I did not add a Fixes tag, nor a > > > Reported-by: kernel test robot. > > > > I think that the Reported-by tag should always be included but I agree > > that a Fixes tag is not necessary for this warning, as we currently have > > it under W=1, so it should not be visible under normal circumstances. > > ACK. > Marc, can you directly add below tags to the patch: > > Reported-by: kernel test robot > Tested-by: Nathan Chancellor Please use: Tested-by: Nathan Chancellor # build To make it clear that I didn't perform anything more than a build test to see that the warning is fixed. Cheers, Nathan