From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 084DDC433F5 for ; Wed, 27 Oct 2021 09:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8D6661052 for ; Wed, 27 Oct 2021 09:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241237AbhJ0Jhq (ORCPT ); Wed, 27 Oct 2021 05:37:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:65461 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241205AbhJ0Jhn (ORCPT ); Wed, 27 Oct 2021 05:37:43 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10149"; a="316325577" X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="316325577" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 02:35:17 -0700 X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="597295484" Received: from smile.fi.intel.com ([10.237.72.184]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 02:35:15 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1mffKi-001QZK-3E; Wed, 27 Oct 2021 12:34:56 +0300 Date: Wed, 27 Oct 2021 12:34:55 +0300 From: Andy Shevchenko To: Qian Cai Cc: Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: Re: [PATCH] bitmap: simplify GENMASK(size - 1, 0) lines Message-ID: References: <20211026144108.35373-1-quic_qiancai@quicinc.com> <397751ea-536b-af3c-752d-c4b1045e6e56@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <397751ea-536b-af3c-752d-c4b1045e6e56@quicinc.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 26, 2021 at 03:33:48PM -0400, Qian Cai wrote: > On 10/26/21 3:21 PM, Andy Shevchenko wrote: > > Can you explain to me how it is supposed to work? > > > > For example, > > > > x = 0xaa55; > > size = 5; > > > > printf("%lu\n", find_first_bit(&x, size)); > > > > In the resulting code we will always have 5 as the result, > > but is it correct one? > > Sorry, my bad. GENMASK(size - 1, 0) would just become __GENMASK(size - > 1, 0) instead of 0. Let me revisit it and run some tests first. And we do not want to have __GENMASK() in the code. Btw, I found one lurking around. Will fix it. -- With Best Regards, Andy Shevchenko