Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp897078rbb; Sun, 25 Feb 2024 08:52:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/ARVzZQGFCNyPXSI0XuT/+0IesOewQ4t007bcnmDApgJVe02wHwlz/7J/pe3YS4XuB1xcot1oaR/lxsNziQ+a/lGpu3jTiKaGsiSsbw== X-Google-Smtp-Source: AGHT+IGTa2/k/jtPa2xGEw0R0CcuuKgn5KV4zBnKvpGB04eDs1pABSXtnj8EF377addvdWOk+bao X-Received: by 2002:a17:906:6851:b0:a43:574a:92d4 with SMTP id a17-20020a170906685100b00a43574a92d4mr18354ejs.63.1708879963759; Sun, 25 Feb 2024 08:52:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708879963; cv=pass; d=google.com; s=arc-20160816; b=Kdi1GoPVFiT/ilWiTAaQDApH/TYegE5U+fdsUEWqIt/3UPJozkP+dd5qVZf51SFF4I xzZ1poMv7DIg1TG/HQxqmygZxrjHv4EQm5Tw/DSn4C54kW+N6R8uF/jyw/CmmN6Mm8Jb 5jVXZt8JC88qeWxxT9rnysZ6AknAxpUsneMkTZc+E4cJe31AlH6Eo2u91NFfCUe60TxA 4lBME7JMJLCnGJQXiMU45Nr8E1mnru5Nm2OnZMGPBRNRZpXUtISjsgiBF5OwR/jDkdHT uU4s+kcr0MAAQaySjlR6lYQR60NgiV6J3BfPVbxLnOEcA4XnyMmQRbtvqolvAVO67541 457A== 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=p1h/WKmE5TF4FCWJPfWjd31PeI+Z8RvU39ecIF5kChM=; fh=nGE692sbVdRvha6RYbzMUXtm1nr/30sV7frdtDN2z14=; b=yDESht/dOYE2ZwJbZYsA85Vijh52PwzLkAQBAJLMmEdH2CglMM1t3wp61kQ8H3Pj5H tb7nmHnKoLGNoj+9Ezm7UAoAE0X8uz4W7xX4UrjJvWUIGLO9S6/ZIH5k0m0vRPTb2NAM tTg2cTB/x51T4MFIjB5MT/zKEuFsKYpmzC+U6RUPohc18wZoZCfRzvnwazX5ds0bKLGa ipICITbOPEwXKYPyvmoPOJLSR14SNZn2y4l3zj1LscqECvT6QuNnboRwwhNt9WL/QjCu CHHFLcwA83OX+FHurelG9phsq2YURLrzrygbY+VGcK1+tpT77Wypbs/d14/+uI9cmvP6 aJvQ==; dara=google.com 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-80215-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80215-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bk3-20020a170906b0c300b00a3fc1f18be9si1414388ejb.550.2024.02.25.08.52.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 08:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80215-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-80215-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80215-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8301D1F21630 for ; Sun, 25 Feb 2024 16:52:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0602318AF8; Sun, 25 Feb 2024 16:52:31 +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 6CE5717BC2 for ; Sun, 25 Feb 2024 16:52:27 +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=1708879950; cv=none; b=E/YlOZqOkdZ/VNF7TskXwFa8kXq6HTUgAeTXFFNvgkUq5PYZlPevLA1qaZExkvBpLcUeDemg/MA6NjjjEgomq9Qw81pj3OtRjduw5YImRoLgU8j0xKDsR6ba8XOi5OPTlDcyoQhIeAwKNwNzQRg8HsIHLdeJKqBiJSk3q/xoPCk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708879950; c=relaxed/simple; bh=dxzwutw/uYInR/fAygjwtW6vRzUH7ChzCxCY1kqoRdc=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=NINFFiW6v+cKxXkz2pPZsBaJACW8A/SXvQZsX+XObCWfGNDJRCzt4iMtPmUD/F/g9yBd9QWGa7lxoxLaVMoKCo2wbKUjhquWRagwBYm/oG9lUzlpXZ6nsVNZWb9bx7nhxHXhNF2olfSuBItsD8QUiRXAab3PoIh7hTcUIxdLVDw= 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-98-15ZuON0NN0C4fR-488HG-w-1; Sun, 25 Feb 2024 16:52:24 +0000 X-MC-Unique: 15ZuON0NN0C4fR-488HG-w-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, 25 Feb 2024 16:52:22 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 25 Feb 2024 16:52:22 +0000 From: David Laight To: "'linux-kernel@vger.kernel.org'" , "'Linus Torvalds'" , 'Netdev' , "'dri-devel@lists.freedesktop.org'" CC: 'Jens Axboe' , "'Matthew Wilcox (Oracle)'" , 'Christoph Hellwig' , "'linux-btrfs@vger.kernel.org'" , "'Andrew Morton'" , 'Andy Shevchenko' , "'David S . Miller'" , 'Dan Carpenter' , "'Jani Nikula'" Subject: [PATCH next v2 06/11] minmax: Remove 'constexpr' check from __careful_clamp() Thread-Topic: [PATCH next v2 06/11] minmax: Remove 'constexpr' check from __careful_clamp() Thread-Index: AdpoCvvrOCX/oa+QSiiCG9QfHbI0jw== Date: Sun, 25 Feb 2024 16:52:22 +0000 Message-ID: References: <0fff52305e584036a777f440b5f474da@AcuMS.aculab.com> In-Reply-To: <0fff52305e584036a777f440b5f474da@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(-) Changes for v2: - Typographical and spelling corrections to the commit messages. Patches unchanged. 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)