Message ID | 34d53778977747f19cce2abb287bb3e6@AcuMS.aculab.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15FC7D591AC for <linux-mm@archiver.kernel.org>; Mon, 18 Nov 2024 19:13:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A029B6B008C; Mon, 18 Nov 2024 14:13:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B2156B0093; Mon, 18 Nov 2024 14:13:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 879C56B0095; Mon, 18 Nov 2024 14:13:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6AF806B008C for <linux-mm@kvack.org>; Mon, 18 Nov 2024 14:13:40 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DF05A1A04C6 for <linux-mm@kvack.org>; Mon, 18 Nov 2024 19:13:38 +0000 (UTC) X-FDA: 82800163740.15.57B342F Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf03.hostedemail.com (Postfix) with ESMTP id CA5F320002 for <linux-mm@kvack.org>; Mon, 18 Nov 2024 19:13:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf03.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731957034; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DLnsRHfCjtWxXwmCaXLQoT++BY50b46si2gHIz+U13M=; b=lujDaGaKmB3usdjr7AbRIZdhqyL3axMJsLhcYoFt+/65sTsheX717EhonHrsN41d0ywuAo zeoMvxZeHZD7B7NA2Kfo8byUC1+64/LRNlEn6BTfgiywtiOzc6nO0BbafZ+yfRPYkGhnwH w3mZoDXkD0csHb0Xir4QxGAIcu0V7EI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf03.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731957034; a=rsa-sha256; cv=none; b=H3+dzXX373VoL/6VhipqCQp+KYPdfHkCuGw2naylwT27cMTJEGLIyD4Wwrkgqdx5QnJanR BIENfrAU5MdvGHxvh/vzreTpNqNgx5mJmFr/q3gjSHLonXZTmy9ctKIgxJn2F7L1/ezmZ0 eSFCcN7drSwzbziU6rid+ek2f4BLU0c= Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-53-8QuoD1GfPLOo-8Il3CnRIg-1; Mon, 18 Nov 2024 19:13:33 +0000 X-MC-Unique: 8QuoD1GfPLOo-8Il3CnRIg-1 X-Mimecast-MFC-AGG-ID: 8QuoD1GfPLOo-8Il3CnRIg Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 18 Nov 2024 19:13:32 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 18 Nov 2024 19:13:32 +0000 From: David Laight <David.Laight@ACULAB.COM> To: Linus Torvalds <torvalds@linux-foundation.org> CC: 'Arnd Bergmann' <arnd@kernel.org>, "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>, 'Jens Axboe' <axboe@kernel.dk>, "'Matthew Wilcox'" <willy@infradead.org>, 'Christoph Hellwig' <hch@infradead.org>, 'Andrew Morton' <akpm@linux-foundation.org>, 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>, 'Dan Carpenter' <dan.carpenter@linaro.org>, "'Jason A . Donenfeld'" <Jason@zx2c4.com>, "'pedro.falcato@gmail.com'" <pedro.falcato@gmail.com>, 'Mateusz Guzik' <mjguzik@gmail.com>, "'linux-mm@kvack.org'" <linux-mm@kvack.org>, "'Lorenzo Stoakes'" <lorenzo.stoakes@oracle.com> Subject: [PATCH next 4/7] minmax.h: Use BUILD_BUG_ON_MSG() for the lo < hi test in clamp() Thread-Topic: [PATCH next 4/7] minmax.h: Use BUILD_BUG_ON_MSG() for the lo < hi test in clamp() Thread-Index: Ads57fNMrPBo0VpjT1C2YVoqcr+8eA== Date: Mon, 18 Nov 2024 19:13:31 +0000 Message-ID: <34d53778977747f19cce2abb287bb3e6@AcuMS.aculab.com> References: <c50365d214e04f9ba256d417c8bebbc0@AcuMS.aculab.com> In-Reply-To: <c50365d214e04f9ba256d417c8bebbc0@AcuMS.aculab.com> 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 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GGEXM2LKcVL7OPOJKOl5ICNkVVQh0RZk7ZExUv_X_W4_1731957212 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-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oF+LlFCZtYlW5Bh uDTdX4wo oduDGYujcN5Robbre8jImx2Q3elMWmLMRfo6KAu4VQ0fVSOBW2WuBWZBMuPdX+o/h0fL8duPdIsy2rgjAN9Cgn3C+O6FZae0nsP/MT3CMQeYT0bIn7UrGclhZkGgyxBp1C5uPVQ++KW/Oc+i1H+EpBPSBgPQkURRqydgPBcOgc1eNMkg9qAJJtOJSVP7mc1CLXj/hmT5xckiiBCR5D13ZtP/QYX6bTHsUgIZKlNfdzHl5WiNL8DEWrPZ24FgLBXgwLjoVNOpZD2quiITjwdsryIywFsunJRL/fAkyzH7F9WL/vuBsZJg5/b+TB0POLyXKJKatTOgdtTonpgM5CuuoLMMtvHVheS+pk7hf852KwV8iUyppNuQbmpeldNMbhnLyeZki5oSdgu4c0dLpvYs5jVevVDXYMxR/LwrH03OEBMGF+Rvyx6GKQdBOjqMjo8z/Gys4cb1dNeMS53EToOPtSGaDmslaF+O7NTwU0JiA8c3q6Q5zlZaxrxBsUg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
minmax.h: Cleanups and minor optimisations
|
expand
|
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 6f7ea669d305..91aa1b90c1bb 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -106,8 +106,7 @@ __auto_type uval = (val); \ __auto_type ulo = (lo); \ __auto_type uhi = (hi); \ - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ - (lo) <= (hi), true), \ + BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ "clamp() low limit " #lo " greater than high limit " #hi); \ BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \
Use BUILD_BUG_ON_MSG(statically_true(ulo > uhi), ...) for the sanity check of the bounds in clamp(). Gives better error coverage and one less expansion of the arguments. Signed-off-by: David Laight <david.laight@aculab.com> --- include/linux/minmax.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)