Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3570359pxj; Mon, 24 May 2021 09:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRABDenQg0WVqY7mlvTkntfzj5CpFyg6XBBCuq6mgtkr3hghzr7oUT/s1XPoOWIm5mRU8Q X-Received: by 2002:a92:d34a:: with SMTP id a10mr14518991ilh.123.1621874147055; Mon, 24 May 2021 09:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621874147; cv=none; d=google.com; s=arc-20160816; b=XrY8mZoYilcwmcaz4qshUfCPWREG31KVQO6Jkx+XJkF6/DwbsyzWpdJ2F5gxhk0Xzv bFH8KliAwPgKjMZ0MzXhLdRS1poAt0WLh5uoSmIrFYtn+imSWV3CpPSMGIqoVo/+hCzb pyimG7OPVR0uS1+0R1uEVUXRjF8dFpoNcUn4PQ24WenSis8hFYVp7SrNtcnbHRIWQg3g ouYJvSyj9VVGU1aj41tfz4pcMZe1hcsmE5gf4Kgy7XddjOtl2PC23UXd9t3Sv4wvkpCu NjgztA0+cABROECkVmhO8F0Fijf0zLPzR9nx00krJZV3tngBZKA84OTAjHSkWdY0bb5x B3rg== 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=sFW6+RdXoULhue8kaJiQz0JFZk1S8xYlieD2cbE6zQ0=; b=OT/g93IhTYtcn+zkP/8Eu61EyFaxVkiehPqLiAeymY4d2ZnhvoP/hU/ojSBrmyv8ZF /vidqKE0mRxi+0vHHLIFmSiIhpTUHw0vrKQM7JglZbViREiNeQ3MlMRl5hP6kBvEeEzR nQ5sYfnWveZIa7JQF6tqfjE2Z2EpRBzxnJ7QaNRbMYFL89nPxCBsgjh6lIXpGulgnpQP FypolvE53uu5sW7wEljqTIG3MEHD5Po8VY5PtazMtdG1xTP6WRWRfvBBKggLalG0n9/L pVaIFInYf8MfuUBIlLAD6ggFBrYGK4vswfzdok5N4zVgSCunn+eDYTRFVg8PNiqwgFxL pA3w== 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 v3si15227506ilq.36.2021.05.24.09.35.33; Mon, 24 May 2021 09:35:47 -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 S232491AbhEXQgP convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 May 2021 12:36:15 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:22017 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232797AbhEXQgO (ORCPT ); Mon, 24 May 2021 12:36:14 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-130-Su6f02UuPwmFID_yslxeDA-1; Mon, 24 May 2021 17:34:43 +0100 X-MC-Unique: Su6f02UuPwmFID_yslxeDA-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.2; Mon, 24 May 2021 17:34:39 +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.015; Mon, 24 May 2021 17:34:39 +0100 From: David Laight To: 'Mark Rutland' , Christoph Hellwig CC: Joe Richey , "trivial@kernel.org" , Joe Richey , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , "H. Peter Anvin" , Paolo Bonzini , Lorenzo Pieralisi , Mauro Carvalho Chehab , Zhangfei Gao , Zhou Wang , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-media@vger.kernel.org" , "linux-accelerators@lists.ozlabs.org" Subject: RE: [PATCH 0/6] Don't use BIT() macro in UAPI headers Thread-Topic: [PATCH 0/6] Don't use BIT() macro in UAPI headers Thread-Index: AQHXUJhmyhlvadTh4EyDNcSC3h2x96ry0v3w Date: Mon, 24 May 2021 16:34:39 +0000 Message-ID: <56cdb86fe8984a94b4a7a8073476d849@AcuMS.aculab.com> References: <20210520104343.317119-1-joerichey94@gmail.com> <20210524122901.GH1040@C02TD0UTHF1T.local> In-Reply-To: <20210524122901.GH1040@C02TD0UTHF1T.local> 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: Mark Rutland > Sent: 24 May 2021 13:29 > > On Mon, May 24, 2021 at 12:46:26PM +0100, Christoph Hellwig wrote: > > On Thu, May 20, 2021 at 03:43:37AM -0700, Joe Richey wrote: > > > This patch series changes all UAPI uses of BIT() to just be open-coded. > > > However, there really should be a check for this in checkpatch.pl > > > Currently, the script actually _encourages_ users to use the BIT macro > > > even if adding things to UAPI. > > > > Yes. In fact it should warn about BIT() in general. It is totally > > pointless obsfucation that doesn't even save any typing at all. > > That's not quite true; the point is that if you use BIT() consistently, > then even when you refer to bits 32 to 63 you won't accidentally > introduce shifts of more than the width of int, and the definition will > work equally well for assembly and C, which isn't true if you use `1UL` > in the definition. > > With that in mind it's shorter and clearer than its functional > equivalent: > > BIT(x) > (UL(1) << (x)) > > So IMO it's preferable to use BIT() generally, or _BITUL() in uapi > headers. And then, suddenly the compiler warns about truncation of the high bits when ~BIT(x) is used to mask a 32bit value on 64bit systems. Once the C standard committee had decided to change from K&R's 'sign preserving' integer promotions to 'value preserving' you always lose somewhere. Personally I prefer hex constants - I can't count bits at all. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)