From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796555380; b=veYp+mnuZyQlMuS9WuLWtskKXoUY+00xVFyhd+YAqByTqIQHfGagDR4mf2u9yi8l48DR jqtALZ1HHPjCdQOIuJn7g0sXtisyC6bL1z235hN0DISXALRN5bzy7cJdGKhWpDtZvvDX3 QehybkAs0fficBIOL/fpkF9MAz8qQPqgtSdY1V8y+z8G+7eNyTWLEnSHw+es+BdVCBwJZ OQktXUDxOMy8UgBr4GXoIXBlxF/II5ORuB0j9gbGJd+dDhvfEL2hN6qbnXvxBgdjtUSWv 7CNuUfuq7I9XmsSCFeVinMnWYTjuAanxp9Wzckmyosrkn6v0qEaqcw/By4ZaLStG7Rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796555380; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=Figtt6GY2qtH6Mryc5lKdqRTsO0NLh+HGecmit5LeeY=; b=P4V4QB8ivvyky0aNiVUAzaMMIMVydX+iNiRw5OziMbHNTiJiuHDhEuBo8HDGpiWUdXPy Kxzq1P0iztKKTRerAewkWkog37+09OkcxulWs1mnOuCm/gKmT0V29eWV4GJ6E9LV6MoQ6 SjRm2YvEHrTLK2NbC/HCOMyilWIHnqCxWuKkM2hgdgpttE+iVBphYQcSd/yCpEPHwEv8f ygpigDMms7JOm+seKMzPTspTOvuVk+uA0lw5FxxJu6qCu3HyY8MHXTp0CBuu/ht3yu//M /AF6LmrywK+JNqWjTyAlcSYZb/QwI16DUSdf9kEB4Y1GM3k+VYf2b6Xba4Ye21iecaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Rdewd5TT; arc=none smtp.remote-ip=192.198.163.11 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DA04606A31F for ; Sun, 6 Dec 2026 11:09:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DA04606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Rdewd5TT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796555380; x=1828091380; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Figtt6GY2qtH6Mryc5lKdqRTsO0NLh+HGecmit5LeeY=; b=Rdewd5TTGN2wXKckPpJ5xLNBUqBItKU1bQl91/1qP2685/KaLGDTvrIU VBSDQ7AsWzc/gWkJLvfmRBcgnVPm+2qaWgTl1e4jOyIodbAWSPiGENASW 34V9pwAbSrn84vP+ElLbAxkgZAznr0s8cAQ+6cdP3bcIC2xsWgQj581uK G/05N/QLPaFjmPOfBntC3goB9cV6W/pK+VX03Bhy0Gd+T9mayEkm60huC 9w9bDPXi9YfDN47YgNSou6EKHu8ERhfUWR5OrRWZc1Y/Fq88TmquVF9su EknKADMqp+BJ93iGR7zU9TDVYwIVPZsEPvmX1g1K+HFLZxKtpH6B3IY8K A==; X-CSE-ConnectionGUID: toGi1IRTQACqKLMaw/sYlA== X-CSE-MsgGUID: TB7cOS4fQviLuQo8o6tFxw== X-IronPort-AV: E=McAfee;i="6800,10657,11988"; a="5386146" X-IronPort-AV: E=Sophos;i="6.29,81,1794902400"; d="scan'208";a="5386146" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2026 03:09:39 -0800 X-CSE-ConnectionGUID: zyBALWSLQteraXoLbYUCfw== X-CSE-MsgGUID: qmJVchWfSk+/3VIpsM3AEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,81,1794902400"; d="scan'208";a="14760382" Received: from conormcd-mobl2.ger.corp.intel.com (HELO localhost) ([10.245.245.176]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2026 03:09:37 -0800 Date: Sun, 6 Dec 2026 13:09:34 +0200 From: Andy Shevchenko To: Yury Norov Cc: Arnav Kapoor , Yury Norov , Rasmus Villemoes , Jonathan Cameron , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] bitfield: kunit: test FIELD_FIT() with values that overflow the shift Message-ID: References: <20261204163317.924658-1-kapoorarnav43@gmail.com> <20261204163317.924658-3-kapoorarnav43@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Sat, Dec 05, 2026 at 02:43:49PM -0500, Yury Norov wrote: > On Fri, Dec 04, 2026 at 07:26:13PM +0200, Andy Shevchenko wrote: > > On Fri, Dec 04, 2026 at 10:03:12PM +0530, Arnav Kapoor wrote: ... > > > +#define CHECK_FIT(mask, val, res) do { \ > > > + bool fit = FIELD_FIT(mask, val); \ > > > + \ > > > + KUNIT_EXPECT_EQ_MSG(context, fit, res, \ > > > + "FIELD_FIT(%s, %s)", #mask, #val); \ > > > + } while (0) > > > + > > > +static void __init test_bitfields_fit(struct kunit *context) > > > +{ > > > + s32 big = BIT(24), neg = -1, min = S32_MIN; > > > + u32 three = 3, four = 4; > > > + > > > + CHECK_FIT((u32)0x00000300, three, true); > > > + CHECK_FIT((u32)0x00000300, four, false); > > > + CHECK_FIT((u32)0x00000300, neg, false); > > > + /* These must not pass by having their high bits shifted out */ > > > + CHECK_FIT((u32)0x00000300, big, false); > > > + CHECK_FIT((u32)0x00000300, min, false); > > > + CHECK_FIT((u32)0xf0000000, big, false); > > > + > > > + CHECK_FIT(GENMASK(9, 8), big, false); > > > + CHECK_FIT(GENMASK(9, 8), min, false); > > > +} > > > > #undef CHECK_FIT > > I missed your comment here while moving this patch in bitmap-for-next. > This is .c file, so this CHECK_FIT can't pollute anything else. Yes, but this is not the point. > Can you explain what for the #undef? If it's really needed, I'll add it > inplace. Sure, the rationale is purely because it's a set of test cases. We might have more than a single test against something, say called "FIT", and we may want to use the same name of the macro for slightly different data. You may argue that this is not a good style, but I can answer that this is test cases and sometimes it might make sense. So, in test cases I prefer robustness over implicit assumptions. -- With Best Regards, Andy Shevchenko