Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3413751rwa; Tue, 23 Aug 2022 04:29:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6AxKq1I0V3axCZHVzG1P4uF6AXS5cDbjYmzS9RIFMMbu5hZJtRp79oYsgmgX8FI7vAw1IN X-Received: by 2002:a05:6402:1d54:b0:446:5f0e:b261 with SMTP id dz20-20020a0564021d5400b004465f0eb261mr3290212edb.352.1661254199103; Tue, 23 Aug 2022 04:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254199; cv=none; d=google.com; s=arc-20160816; b=ZZwJ/ZPlwafplXt+ABeTbhm4jM71AppeO7WvkBFdVYARllKXit9mxVLn7eSRut9c7G S+oVXy5yHgTu7U3biTmgrgJeT91tEEkl/8ggdSvYyigOjwueWwG9BJ83ob4Q6BpkF410 xrtkBb0CuDivoI2m2RLPqaIaxn02K2ymkiIfNrlcFPWqHbloSy52ZQyh/dI3SnxT+hNE ki9fOivGnMR8IPbhKSvhD/mykyzW1KP5NkaDsyglXUatQ0+bcMXoxepU29J+47eqHWjv FqIlDHBI4z8ksxCD4WHElFm5NIgt6pRLO40tKAhaC7xjzOCVd2YhuhuNlhlpYRxJtiGw Vl+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8+yQX56oQs0hIo3J2kYle5aG15NYVJUvMCGknlph7Q4=; b=X8/Nqa0I/Xtrs2pC6urBGpWSdgrfKEFbuR+Ty5znDYXKTHdX6iBQYlyfN3v98Vz+4t ETW6VqjxkPORvO+/Au+EcfKWRyC3l5vdqqlzHfA/N5Yf/91dzSdTyN4dJY7sjk3ITaa5 I3z7IptIwGSUhnJpkL60IOy+XKmVAJMkIuFI5M13z1XDoMg88kdYUPgxlRKulNVdTUmx CUQhzaVI+k8at+lNOVrL+9NqzwVs9YImDbw7ISHT6eldw4UjXob2F4sNTDlSziS5n5yP bjopA6ys8shAT8SHItzkPUihWAJ7Vv3qRrbTcSCf1j4wz8wiYnLvO2GIBXc1ohT6QJlE xScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b8cD+AjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v19-20020a50d593000000b00441ec11be8esi1694285edi.111.2022.08.23.04.29.33; Tue, 23 Aug 2022 04:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b8cD+AjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356237AbiHWKx4 (ORCPT + 99 others); Tue, 23 Aug 2022 06:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355946AbiHWKp5 (ORCPT ); Tue, 23 Aug 2022 06:45:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB126CF51; Tue, 23 Aug 2022 02:11:28 -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 177326069D; Tue, 23 Aug 2022 09:11:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A0FBC433D6; Tue, 23 Aug 2022 09:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245887; bh=xbUiAn6roGKlOVmttkOBenGDG4+k4twIaoCVAlzAAPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8cD+AjInpX6PsiVFHXP3OP2WPxfwWYGoZ6QFuVxp765nF5tt9Le1qBtgFT1gB6YP 3CWSlPh00yQoYGR5Suz7CHhEWd+HGxgZHp0eQeLwJLy9CD9mKO3jJzrBdKgqiHhrX7 kRtD+svXAwarEMBlM91xm50I2vxiTJfe7JlKBVCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerhard Uttenthaler , Sebastian Haas , Marc Kleine-Budde Subject: [PATCH 4.19 222/287] can: ems_usb: fix clangs -Wunaligned-access warning Date: Tue, 23 Aug 2022 10:26:31 +0200 Message-Id: <20220823080108.467764856@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Marc Kleine-Budde commit a4cb6e62ea4d36e53fb3c0f18ea4503d7b76674f upstream. clang emits a -Wunaligned-access warning on struct __packed ems_cpc_msg. The reason is that the anonymous union msg (not declared as packed) is being packed right after some non naturally aligned variables (3*8 bits + 2*32) inside a packed struct: | struct __packed ems_cpc_msg { | u8 type; /* type of message */ | u8 length; /* length of data within union 'msg' */ | u8 msgid; /* confirmation handle */ | __le32 ts_sec; /* timestamp in seconds */ | __le32 ts_nsec; /* timestamp in nano seconds */ | /* ^ not naturally aligned */ | | union { | /* ^ not declared as packed */ | u8 generic[64]; | struct cpc_can_msg can_msg; | struct cpc_can_params can_params; | struct cpc_confirm confirmation; | struct cpc_overrun overrun; | struct cpc_can_error error; | struct cpc_can_err_counter err_counter; | u8 can_state; | } msg; | }; Starting from LLVM 14, having an unpacked struct nested in a packed struct triggers a warning. c.f. [1]. Fix the warning by marking the anonymous union as packed. [1] https://github.com/llvm/llvm-project/issues/55520 Fixes: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface") Link: https://lore.kernel.org/all/20220802094021.959858-1-mkl@pengutronix.de Cc: Gerhard Uttenthaler Cc: Sebastian Haas Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/ems_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -206,7 +206,7 @@ struct __packed ems_cpc_msg { __le32 ts_sec; /* timestamp in seconds */ __le32 ts_nsec; /* timestamp in nano seconds */ - union { + union __packed { u8 generic[64]; struct cpc_can_msg can_msg; struct cpc_can_params can_params;