Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2239152pxv; Sat, 24 Jul 2021 09:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXhzwYPl+XlXGFukfmJYwyJsssJnF0URTUGz/gNCYB8rb9AaXe9Ci0oP2AFmjLw8LhaasA X-Received: by 2002:a02:90d0:: with SMTP id c16mr8980837jag.106.1627144462785; Sat, 24 Jul 2021 09:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627144462; cv=none; d=google.com; s=arc-20160816; b=CehS07bcwbDXgmjiO1YGDejE4y9d4Q7bJW09c140TNUSdCtCjt1sZLaeGjiis3FiH3 FkpYdjAlxBFyJ85dmF6mSzzJK1a4+OHECh4wDT/2paBEe+KPrFAoaCPBP0GlZtb0pNzh p9dmL9pqfr6CNlX3w+YZzVeUbiyOnyyyx6ND4wv0FqY1h7Ib0OZ5gji4NLTNzZFzNHGq UbuR127Auucc/pM9YZiIK/rKC7iQNgUbb2VigIl7d5UmDTCk+bDBVIrfxf4rb0qe8Qey 5RGTPcvt49Fcit7uVG7N5Q7zQ5Yn2SGs8IvD3U0XFTzJ6Qq8DrDspOKcKy6dx1BN6T5V JQ/g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=VlraKBfCz4HcEEphEEUFJxpqY7WKDh5jCjkPEkIoSOo=; b=gw+8RZ0Ug8ym2cqGFm8oJIRBWhHoDrDZkBUA1+6Kmdc4A3kThMOFtyRD96sgucF2es SAN5uzPX1z2p3/yjnrBCBZ35RhxysaEb/+w/jfkypFdMrWe+UjO6hRxI7mCRR/GAvgDm kwJeAVBRPBYvi4xJW5yz3MiM6WEf2TVaa/BvcUjz5haVB4AHyP4m4TLWIrgrmJm+bHbE /ybrW2asHAw7ycewaRha30s+6Gd7QZWSskYWNFQ6We80RSYzgWPct13qHVN7co1IbHhE 3EkfDNzH2irueSqN2LwergTxOQB2JRLtMgKDFH9P0hOovkxnS98m7OCo1kwO2GdKmlfJ RxUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@narfation.org header.s=20121 header.b=vraSgcfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=narfation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si25936423ilo.2.2021.07.24.09.34.11; Sat, 24 Jul 2021 09:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@narfation.org header.s=20121 header.b=vraSgcfn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=narfation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbhGXPwX (ORCPT + 99 others); Sat, 24 Jul 2021 11:52:23 -0400 Received: from dvalin.narfation.org ([213.160.73.56]:36986 "EHLO dvalin.narfation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbhGXPwW (ORCPT ); Sat, 24 Jul 2021 11:52:22 -0400 X-Greylist: delayed 492 seconds by postgrey-1.27 at vger.kernel.org; Sat, 24 Jul 2021 11:52:22 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1627143876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VlraKBfCz4HcEEphEEUFJxpqY7WKDh5jCjkPEkIoSOo=; b=vraSgcfngtPJ5cG1c7K18mNFPKbUyQjtOynHdMdNi/mqG7QZjlTI4A9H+HrArp5Xd3oJW4 3WH9aXK5UEKQeKJUTAwqd55zEujLFbycKYr8elquAXYlfNOQ2GlEpzNoQzAv3bBlJGGtvR 5mXHQ5YkNe+mpvctxK67f4mfT4hjRBQ= From: Sven Eckelmann To: Arnd Bergmann Cc: b.a.t.m.a.n@lists.open-mesh.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Sven Eckelmann Subject: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning Date: Sat, 24 Jul 2021 18:24:29 +0200 Message-Id: <20210724162429.394792-1-sven@narfation.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse will try to check casting of simple integer types which are marked as __bitwise. This for example "disallows" simple casting of __be{16,32,64} or __le{16,32,64} to other types. This is also true for pointers to variables with this type. But the new generic {get,put}_unaligned is doing that by (reinterpret) casting the original pointer to a new (anonymous) struct pointer. This will then create warnings like: net/batman-adv/distributed-arp-table.c:1461:19: warning: cast from restricted __be32 * net/batman-adv/distributed-arp-table.c:1510:23: warning: cast from restricted __be32 [usertype] *[assigned] magic net/batman-adv/distributed-arp-table.c:1588:24: warning: cast from restricted __be32 [usertype] *[assigned] yiaddr The special attribute force must be used in such statements when the cast is known to be safe to avoid these warnings. Fixes: 803f4e1eab7a ("asm-generic: simplify asm/unaligned.h") Signed-off-by: Sven Eckelmann --- include/asm-generic/unaligned.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h index 1c4242416c9f..e2b23e5bf945 100644 --- a/include/asm-generic/unaligned.h +++ b/include/asm-generic/unaligned.h @@ -10,12 +10,13 @@ #include #define __get_unaligned_t(type, ptr) ({ \ - const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + const struct { type x; } __packed *__pptr; \ + __pptr = (__force typeof(__pptr))(ptr); \ __pptr->x; \ }) #define __put_unaligned_t(type, val, ptr) do { \ - struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ + struct { type x; } __packed *__pptr = (__force typeof(__pptr))(ptr); \ __pptr->x = (val); \ } while (0) -- 2.30.2