Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1956215ybm; Sun, 31 May 2020 04:04:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZystFvAxjGONId2Jeocjq046pOEZLjfXdriJoHfQgqyqwGWDRpTF2CaO1JlYSq5sLtAXp X-Received: by 2002:a05:6402:8d1:: with SMTP id d17mr16059321edz.38.1590923053987; Sun, 31 May 2020 04:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590923053; cv=none; d=google.com; s=arc-20160816; b=UP4YQidpB5y+2zaoeQXhXNtC30ZeWZ5a8Ia7Aih4Ac5USRZ0ILk8UGnSeibxURSTj5 z1bSipcp1Nqv/TZxQsbBjlDbxS9RIV/JJn88E1wg0F0CaknJlCBLA7w757YRGlO7UFzR D2GtX1nAK/SFuNYK6z6C6YbvmI3yCzUXTGE7B8OM1ZIJ57AP/ZtklWU1/OkPJW4IhXC4 tOIM3E0Wwcx2GTcCOdCK3osE8No2QvOT9WtRp4up17KAj9Df7Qy5ma65xwE9zobkN3Vt eEwfqiSDEVjhZrNuomrEEKk7R4P9LvSMKWe9S5EA57xZhyCLvRWsHBSqThzLsAdL9qYH RJ5Q== 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; bh=pv6M/ubzOrR2GpHct2V9mx36XIAqlU5lXxjX4nPRe8g=; b=EjMbbfVEi0VKuCYsG+JDvsjiQvY7spCn2esEAS/ThhRWJngnTjf6Q+ZeTnOWjMSegj pLVqFOAe2T9gwx+Dhz0Bh9KsWsBTcztSQTqatvFvxKAew9WxRfzhT2QadssOyhcxjXiy cU/7SBjg+EUdIVqvEnaJh9nPAcBGNbF7ymvCdnsGGzhDZSeIw8EfXub/yjIOw+uVfrfT Mo3AkJ7g5bFgW4nNm39G9nztm9RI+Ej1TcFl45yzpD3Yxtg+Ar4Jr0HS0PqETWOBb+bf NyMDjE9MNSiBnE+Luqcm+Gt1w8XDB5o85lwGf4tn1md2Z+vPzso+QHvLZ31GfcWv6Sb7 7PjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YG4n2UPC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si3854099edx.506.2020.05.31.04.03.51; Sun, 31 May 2020 04:04:13 -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=@gmail.com header.s=20161025 header.b=YG4n2UPC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729612AbgEaLBF (ORCPT + 99 others); Sun, 31 May 2020 07:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728165AbgEaLBE (ORCPT ); Sun, 31 May 2020 07:01:04 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0A6C061A0E; Sun, 31 May 2020 04:01:02 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id n15so2121402pfd.0; Sun, 31 May 2020 04:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pv6M/ubzOrR2GpHct2V9mx36XIAqlU5lXxjX4nPRe8g=; b=YG4n2UPCARQM4F8D3Yzto1lnn1CByWD9LQYK9620mtA0+Nci7rBwlMTuDrz9f7ddtX ZEzZ339tXSj5NzcIfczwsen2Ed9vy5sUz4sEgt8IDelttbchalVGWEvnPiOwAUF7cwAS sUn0S1IvYmJlDuu475OK6gY7zuJQj9SmBpbAIaszTypMIv+q2bYfWYbOYdvMtSvrDfdv iM+nMCU5oJVCSsmYfMUSO4On84V7AiX4aghx2L7S8D/dvXC7/BkbI+QtyAs3BxP8mvXM pLRrhQ0xUapiRdIkwxyXz/3fZyckNSLNhRv22VE2j/k8Bfy/HMEhb5HNxqFvLBbtka73 iSuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pv6M/ubzOrR2GpHct2V9mx36XIAqlU5lXxjX4nPRe8g=; b=JkNenq3ggO0FhfxfnVZLmmFA+Prt7mFyRPKx8ORBLlQWtsic/n2l7vm5yqSACtsjaM 3Bf0MTKQhXGbcjZhhGyNAguUlj4RMBUr3Bie8rVgxXfmSVkMHUHM3lPA86so6sDMtJW0 cnRL3ds2yozKq2irwv40NjpcREqM1McjKbwLXj0fK90hCospm2Yrk3ctEDhlt+19e/oK wdlHjSq0fFuPydtvumAypy+fD22npEY27c6QQxt8oTLAROVrGvO4boTPfrJwXB4bRCIy hghqCIugP3wd5zSHq5fMbWq20jLEt+AR+O3RBgG+SVruDvH3P48FaP7gFAv3506acPsu pO3Q== X-Gm-Message-State: AOAM531Q8fg8nkc9+ul5qHE/nYbvxU2Z+dN/sBND4T530DakqdVTjL7b ARw/TG0bL92pDkUMa1HtydyrFYbGTqgbGrZmu7k= X-Received: by 2002:a63:545a:: with SMTP id e26mr14919928pgm.4.1590922862169; Sun, 31 May 2020 04:01:02 -0700 (PDT) MIME-Version: 1.0 References: <17cb2b080b9c4c36cf84436bc5690739590acc53.1590017578.git.syednwaris@gmail.com> <202005242236.NtfLt1Ae%lkp@intel.com> <20200529183824.GW1634618@smile.fi.intel.com> In-Reply-To: From: Andy Shevchenko Date: Sun, 31 May 2020 14:00:45 +0300 Message-ID: Subject: Re: [PATCH v7 1/4] bitops: Introduce the the for_each_set_clump macro To: Syed Nayyar Waris , Rikard Falkeborn , Masahiro Yamada , Kees Cook Cc: Andy Shevchenko , Linus Walleij , Andrew Morton , William Breathitt Gray , Arnd Bergmann , Linux-Arch , 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, May 31, 2020 at 4:11 AM Syed Nayyar Waris wrote: > On Sat, May 30, 2020 at 2:50 PM Andy Shevchenko > wrote: > > On Sat, May 30, 2020 at 11:45 AM Syed Nayyar Waris wrote: > > > On Sat, May 30, 2020 at 3:49 AM Andy Shevchenko > > > wrote: ... > #if (l) == 0 > #define GENMASK_INPUT_CHECK(h, l) 0 > #elif > #define GENMASK_INPUT_CHECK(h, l) \ > (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ > __builtin_constant_p((l) > (h)), (l) > (h), 0))) > #endif > > I have verified that this works. Basically this just avoids the sanity > check when the 'lower' bound 'l' is zero. Let me know if it looks > fine. Unfortunately, it's not enough. We need to take care about the following cases 1) h or l negative; 2) h == 0, if l == 0, I dunno what is this. it's basically either 0 or warning; 3) l == 0; 4) h and l > 0. Now, on top of that (since it's a macro) we have to keep in mind that h and l can be signed and / or unsigned types. And macro shall work for all 4 cases (by type signedess). > Regarding min, max macro that you suggested I am also looking further into it. Since this has been introduced in v5.7 and not only your code is affected by this I think we need to ping original author either to fix or revert. So, I Cc'ed to the author and reviewers, because they probably know better why that had been done in the first place and breaking existing code. -- With Best Regards, Andy Shevchenko