Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1345241ybh; Sat, 3 Aug 2019 23:49:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBYsX4K2BgJDTFFsPNgbhnwV2IwkLnRUKvreP86feQqrVc6Q008f+wJLLtVfTLWilItZDT X-Received: by 2002:a65:6815:: with SMTP id l21mr43374783pgt.146.1564901359610; Sat, 03 Aug 2019 23:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564901359; cv=none; d=google.com; s=arc-20160816; b=Yo2yMyb0l6G0mFJI4ED1jn1GP8DGlzAGmZJQwopSmsJPjbHDmpnwwrhAeYlzXdR4Dz jgAuOCza0sZpSiy6MTLBZAgRnvt06Qbk/yRmoZ9Ts5GCjMwnamkPPS7qV7bfr+gSmy8d mycz/Qy5is4rzioVDOHjKXj/K7sgyMeYIGL7ryYxsj0BgD2UYG+qIYxr7TClFjGtoVHD sOwc6+4tqb5TGr2kv7qFYEOSjtJBEvtA9ohtYh1ex7fAKhtEv+66MuMS7fXxG8GLsTPN UMZaOj+lfSNTpaOrf1zCbdJKVeKmFwcC/uK3uyXqOyVsVT/KRLecmlOLSLi22M2QOXGc nveA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=je+UTj793agEnh3MYyyqsCIOZWLYGEf4dYfDOWDpCA8=; b=M0TgjZoLRQTjIBG87zXNHFRuHv0znysnNLnfpaJfqxNntzsX3n7kP7AahTx9e1Dj8A 9utaOl9laQE+BkFFHgBDQL/gF7k7gHZ5oPpvQ/XqjCDizHHat4R10gcVndunpiiqT4Yw fVtcNhcAPo8OLujM50df8jDvix8W+/0vCECWfuSi1MLmympY1zloA4ldmNVKHhWAk/q3 rLP9qn0tS5co6PopDaETmER9n8SzhDV8LSbeam8UcZeEh3pltmeEL0EsAWvbIS9FXoX3 //dMOFK/3ENXhO3DYIbKxCAJudWt7Fa9p2Pj0P0Enje5LUylan4HtbtOUMf18xEDYD61 oASQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FO5SM9fP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si44995493pfl.261.2019.08.03.23.48.16; Sat, 03 Aug 2019 23:49:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FO5SM9fP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725936AbfHDGqJ (ORCPT + 99 others); Sun, 4 Aug 2019 02:46:09 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:43910 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfHDGqJ (ORCPT ); Sun, 4 Aug 2019 02:46:09 -0400 Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (authenticated) by conssluserg-05.nifty.com with ESMTP id x746jst5012318 for ; Sun, 4 Aug 2019 15:45:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com x746jst5012318 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1564901154; bh=je+UTj793agEnh3MYyyqsCIOZWLYGEf4dYfDOWDpCA8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FO5SM9fPvl06Arttql8wxB1hDEjj5IEgmyFDl84lBoVv97Kn5I9WlawFmaKRQpnDi PbH+U66RAeSS/unI7f7ozY5K0HFAxa5SRTSx3IaElFgI/KC5gDiiq7JNvTOFxryX6H +GSKH/NY6qbEua0FSqO0HnwQl8U0Xhz2jpxASrGlQ/eyDvDptvZm3vPOXalELis/bG 7R25gfKybDRIRsi+OWtT6EIwV5XrjWalB1kVGQyS9xZ/Y3hjzULrqIbOMfbWsvoC1X 4C35HSBxhVT00t8PS3JZVVj6V9KNpNntJn1njFGswgwqmII8eKy9ugwOAT+eis0yCf PO5fjNRObcgDw== X-Nifty-SrcIP: [209.85.222.45] Received: by mail-ua1-f45.google.com with SMTP id z13so31187511uaa.4 for ; Sat, 03 Aug 2019 23:45:54 -0700 (PDT) X-Gm-Message-State: APjAAAXjQWZvX5aqkvx7xFPVyQIDh0sUmo2Do4baVcmHCQh7d17RLzo4 xsQNc/mfQhJajh8zWl3298X42nAxlTMpR0JcDqI= X-Received: by 2002:a9f:25e9:: with SMTP id 96mr74835901uaf.95.1564901153387; Sat, 03 Aug 2019 23:45:53 -0700 (PDT) MIME-Version: 1.0 References: <0306bec0ec270b01b09441da3200252396abed27.camel@perches.com> <20190731190309.19909-1-rikard.falkeborn@gmail.com> <47d29791addc075431737aff4b64531a668d4c1b.camel@perches.com> <2b782cf609330f53b6ecc5b75a8a4b49898483eb.camel@perches.com> <20190802181853.GA809@rikard> <20190803183637.GA831@rikard> In-Reply-To: <20190803183637.GA831@rikard> From: Masahiro Yamada Date: Sun, 4 Aug 2019 15:45:16 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] linux/bits.h: Add compile time sanity check of GENMASK inputs To: Rikard Falkeborn Cc: Joe Perches , Andrew Morton , Johannes Berg , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 4, 2019 at 3:36 AM Rikard Falkeborn wrote: > > On Sat, Aug 03, 2019 at 12:12:46PM +0900, Masahiro Yamada wrote: > > On Sat, Aug 3, 2019 at 12:03 PM Masahiro Yamada > > wrote: > > > > > > > > BTW, v2 is already inconsistent. > > > If you wanted GENMASK_INPUT_CHECK() to return 'unsigned long',, > > > you would have to cast (low) > (high) as well: > > > > > > (unsigned long)((low) > (high)), UL(0)))) > > > > > > This is totally redundant, and weird. > > > > I take back this comment. > > You added (unsigned long) to the beginning of this macro. > > So, the type is consistent, but I believe all casts should be removed. > > Maybe you're right. BUILD_BUG_ON_ZERO returns size_t regardless of > inputs. I was worried that on some platform, size_t would be larger than > unsigned long (as far as I could see, the standard does not give any > guarantees), and thus all of a sudden GENMASK would be 8 bytes instead > of 4, but perhaps that is not a problem? How about adding (int) cast to BUILD_BUG_ON_ZERO() ? -- Best Regards Masahiro Yamada