Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4223417pxv; Tue, 27 Jul 2021 01:47:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhX1eHx9K4+FbvOLorUC3jPnMbsgQ/Xb6rXGZfyH+YO2awSXoFtHQEys8mYx/lAx0DClNE X-Received: by 2002:a17:906:8252:: with SMTP id f18mr20528339ejx.261.1627375660386; Tue, 27 Jul 2021 01:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627375660; cv=none; d=google.com; s=arc-20160816; b=Y3nmlW7jQgAIptS+nfWx0bpBpfeK1UHZJiGdklCkgd0DwfYnGGeP+ON7SyUB9tllE8 6dTYvCBYSpvHCy8H7s8j39rEgmDBzfGvl1ZPUb7/YuLByI0Uavl2ZieEcq4doxrIv2aa JWd/n5trs7LsICMMuPLhF9/kIwYytX+EWIouin9+MZJeiUTZRYR8ny6HPtJ3TM4OB//2 0YSSFampBkkNiFzKY/oKvhTBBPWDNqqJY9e54UTkmivQjxcPVZmCj8j2ZHljEvRMb7Vx sRqI+uqdSOVg1q9IeL2p+XFF5C8zSsLOFbsfmZmOhiHz4CpGQRgxkJYx3Gzfy5ElPtnw yeQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=GgvPj97FXRpB8nQZpJHpxDyH3QR2kFTQAzyPxyHH0W4=; b=Q0pUsBUWIr8CJgZlH/wn7ahjDYMtHmHhLaA8B4pzyIL+XzRKtd7EdGy6oUJ+TcH5Go LwkSDGZ0bnNguoAvflZOO3X4q2h2ruwvbQypWFBt2u4g95n0Lk53J1CeEKo80Le9g6Y/ hQGBZLv5uJnW622aFlUryhjfKBkdfQS5tM5tBHFgKk3nvm64BbguNyt6O1HCIHygJAHl cuDDDxq9SL/pAc7QtewDbjw88NIESQxNyD70dQE7POmaACiPy95m8K2Mb4bTKdhKdsy+ sFFVBmhS8r28hwGhlnzYWmoThON0oUSKXJco501FtkP0lG16hKWCL8Pu2+wSFTCsZfAm hEfQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si2139735edq.454.2021.07.27.01.47.06; Tue, 27 Jul 2021 01:47:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235885AbhG0Iog convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Jul 2021 04:44:36 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:32055 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235978AbhG0Iog (ORCPT ); Tue, 27 Jul 2021 04:44:36 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mtapsc-2-V9oMQAtEOq6BFHQKDsaWeQ-1; Tue, 27 Jul 2021 09:44:23 +0100 X-MC-Unique: V9oMQAtEOq6BFHQKDsaWeQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 27 Jul 2021 09:44:21 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.023; Tue, 27 Jul 2021 09:44:21 +0100 From: David Laight To: 'Sven Eckelmann' , Arnd Bergmann CC: "b.a.t.m.a.n@lists.open-mesh.org" , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning Thread-Topic: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning Thread-Index: AQHXgKmQSnOHUxbKO0+Mz34J8bnrJ6tWhKAw Date: Tue, 27 Jul 2021 08:44:21 +0000 Message-ID: References: <20210724162429.394792-1-sven@narfation.org> In-Reply-To: <20210724162429.394792-1-sven@narfation.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Eckelmann > Sent: 24 July 2021 17:24 > > 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. At least the __force is being added to an existing cast. The real problems are when a (__force __le32)value cast is used to silence sparse. These should really be something like: __tell_sparce(__le32, value) so that the whole thing can be removed by the preprocessor when compiling the code. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)