Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp21769rdb; Sun, 28 Jan 2024 11:31:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG79DeI7np67N4F28IW63Wmik8SiB1t6pdR8J4uB7f0DkSTMiscXWfcZxbIydgf89srDPKQ X-Received: by 2002:a05:620a:4722:b0:783:fe6b:4c63 with SMTP id bs34-20020a05620a472200b00783fe6b4c63mr729239qkb.61.1706470277062; Sun, 28 Jan 2024 11:31:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706470277; cv=pass; d=google.com; s=arc-20160816; b=sCTuAYch6rOrf3QtxuXRLoPxb9PFMnQ1PZc2IF3bUyYJXHNxC2RBpeBo9KDp6gmk4c 1ymFfC6xPvAQavD1OFzW6Jyb5/rTYRwIDJ2qytGL0H77ELJHIbOVW4Q9aCiG8sCuxaBm qK1gcnUPVkufrtJVx47Lts3s6vHnri+NYf43XHumwelDDfz+8+/pMkTmdZh+GFpohODR PJhwNbbv5HDv+KZsJkOU1QOlGfeN4xfnPm0jH3a8paQYWHUGrFuRoI3XvqSWWk5RouFm FQ10G7+eKiRoQJqU8oIidgLIPbSwGJzD/3Hk1iRye1i5QPdIiSWwstH7epFbkEKunthy wFKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=iWQXPp/qjTTJBhKQWsunQrfAky+A2x8xRAHhkRrF2cU=; fh=jAOu/RGlQxfhPk7PcGNzOfYLHKZO+STAaG1daOB/TAU=; b=BF4g0cE8u0zkSRHM+zh0qzQ1U/K2NTrKIrGFPucjFkc+pqBcXk8KqMEBEHJ7UiLZ4S gMGNKzrnv+mZUukZQcHfZfHiQh4DEyykz9NJCzhv3HBMeIqAe81cqBu4wMxPSN2ZviT4 IhWFGLmnpPISQBVaQ1G0qzAAXWg9UMI+6ZIHIwKTshFckyN6wJxmubnyyOpjyvSLiTeu DoxsvCyQXN8rocsULT9c3DCPD9aKI03PA8QwO10CbjfNfxJ7AD+EPn7jwGAsPfNzG0w7 DG0+4zwSGIVCiL/9zmtGO5jrJ/aYvXP9vlo07fR/Uy6h4MmIYniljgrUrDXQfMmL+XCc CDJg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-41903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l24-20020a17090aaa9800b0029022ab651bsi6423602pjq.173.2024.01.28.11.31.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 11:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-41903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AC65B284E88 for ; Sun, 28 Jan 2024 19:31:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38B7E3BB55; Sun, 28 Jan 2024 19:31:02 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5726231A66 for ; Sun, 28 Jan 2024 19:30:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706470261; cv=none; b=uJkZgnWFo4o23LEmnwqRvOWBCkjmNIdIMcdfInMzCcneaCTwJPCzZs5Pcv6/9hvViR4pKFiEXmxYU8crJ5a/beBK+tfKy8sghuWRfDQXiXu2ofw+yRU+FTid3+yGX97NPAA3KfIIBTKi3Pufl55wX1J4pc0oFzqM32WHVa1FHmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706470261; c=relaxed/simple; bh=+IrvWOPrzG/zw8pSAZuMCFpCBK3uf5ox+sEpIcxcuDU=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=mFvqWUKP2ex5f1Twp0ht7z/1Fmi8gB1C1NKli72A0rSz9WVGjqLmo9xfOl0hdDVKaIw+yVcGacQRb7vkEAPE9fLoXUFiRaBFKi69ShKowktM4Sv0cycLgZbTN8ZCJZSPDpvRaO7JukBBiNlGX2Ttk9qIz+4BiZrOm3DHjW+ErwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com 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-54-7ZbHWpVmPmCGvRjzXyD65A-1; Sun, 28 Jan 2024 19:30:56 +0000 X-MC-Unique: 7ZbHWpVmPmCGvRjzXyD65A-1 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; Sun, 28 Jan 2024 19:30:32 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 28 Jan 2024 19:30:32 +0000 From: David Laight To: "'linux-kernel@vger.kernel.org'" , "'Linus Torvalds'" , 'Netdev' , "'dri-devel@lists.freedesktop.org'" CC: 'Andy Shevchenko' , 'Andrew Morton' , "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , "'Dan Carpenter'" , 'Linus Walleij' , "'David S . Miller'" , "'linux-btrfs@vger.kernel.org'" , 'Jens Axboe' Subject: RE: [PATCH next 00611] minmax: Remove 'constexpr' check from __careful_clamp() Thread-Topic: [PATCH next 00611] minmax: Remove 'constexpr' check from __careful_clamp() Thread-Index: AdpSIH76BAHML8iRQIeOmBtN5r1qZw== Date: Sun, 28 Jan 2024 19:30:32 +0000 Message-ID: References: <0ca26166dd2a4ff5a674b84704ff1517@AcuMS.aculab.com> In-Reply-To: <0ca26166dd2a4ff5a674b84704ff1517@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Nothing requires that clamp() return a constant expression. The logic to do so significantly increases the .i file. Remove the check and directly expand __clamp_once() from clamp_t() since the type check can't fail. Signed-off-by: David Laight --- include/linux/minmax.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 111c52a14fe5..5c7fce76abe5 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -141,12 +141,10 @@ =09=09"clamp() low limit " #lo " greater than high limit " #hi);=09\ =09__clamp(__val_##uniq, __lo_##uniq, __hi_##uniq); }) =20 -#define __careful_clamp(val, lo, hi, uniq)=09=09=09=09\ -=09__builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)),=09\ -=09=09__clamp(val, lo, hi),=09=09=09=09=09\ -=09=09({ _Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness erro= r");=09\ -=09=09_Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error")= ;=09\ -=09=09__clamp_once(val, lo, hi, uniq); })) +#define __careful_clamp(val, lo, hi, uniq) ({=09=09=09=09=09\ +=09_Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error");= =09\ +=09_Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error");= =09\ +=09__clamp_once(val, lo, hi, uniq); }) =20 /** * clamp - return a value clamped to a given range with strict typecheckin= g @@ -168,7 +166,9 @@ * This macro does no typechecking and uses temporary variables of type * @type to make all the comparisons. */ -#define clamp_t(type, val, lo, hi) clamp((type)(val), (type)(lo), (type)(h= i)) +#define __clamp_t(type, val, lo, hi, uniq) \ +=09__clamp_once((type)(val), (type)(lo), (type)(hi), uniq) +#define clamp_t(type, val, lo, hi) __clamp_t(type, val, lo, hi, __COUNTER_= _) =20 /** * clamp_val - return a value clamped to a given range using val's type --=20 2.17.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)