From patchwork Sun Feb 25 16:52:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 206094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1657584dyb; Sun, 25 Feb 2024 08:52:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwyyHr7OQluKbDSj8C+0q2htcCE/OI6lg3CGvqYUUd94JiigPqX/wDPLFY9TfmDSZuqFViSGBiz+LTh4JcTm4aEl/e9g== X-Google-Smtp-Source: AGHT+IFk2KSjyZ5ROBtfGJMV7GnuGG52VshGJEVjJvFBj1iPG3ofLh5EH5qWyvpckZhfvrDxW7Fi X-Received: by 2002:a05:6214:daa:b0:68f:359a:896e with SMTP id h10-20020a0562140daa00b0068f359a896emr7006543qvh.12.1708879971778; Sun, 25 Feb 2024 08:52:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708879971; cv=pass; d=google.com; s=arc-20160816; b=CpXDu2IwNADP2pOcIw7jAFcQQjdwyzut+XGzNpmNXsIfy6mSo9MGn2aITOIsvvnQLi Y7zuryqTC12C7sXPAg8ZO910TEeokKC5HqK9RZKowijnw88YkP/Bw9CjYKpCjOBDGdQV j3GZhl/ltBjL73LFm5a1ngVfEpzw+j1iusa9BghDpFmAYat84YOAyh1PlZVYxQGpCBA1 bNt0KRgZdJWydWvf3CQIu/l4vnBqcaiqcnql2oliSRsXM+qv5HMG6QYTx5NL27Zp7lof BIoP1Vl21xI8oaW1tg9v9QzzHEh5DfMmaB5dI9nHCciX675WIlaQUyZERRCm6FDlmm2h qrSg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80215-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 3-20020a05621420a300b0068f8b9e1ad4si3337884qvd.388.2024.02.25.08.52.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 08:52:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-80215-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80215-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 912B81C20402 for ; Sun, 25 Feb 2024 16:52:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D4AB1A27E; Sun, 25 Feb 2024 16:52:32 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791890525240965219 X-GMAIL-MSGID: 1791890525240965219 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 @@ "clamp() low limit " #lo " greater than high limit " #hi); \ __clamp(__val_##uniq, __lo_##uniq, __hi_##uniq); }) -#define __careful_clamp(val, lo, hi, uniq) \ - __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \ - __clamp(val, lo, hi), \ - ({ _Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ - _Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ - __clamp_once(val, lo, hi, uniq); })) +#define __careful_clamp(val, lo, hi, uniq) ({ \ + _Static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ + _Static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ + __clamp_once(val, lo, hi, uniq); }) /** * clamp - return a value clamped to a given range with strict typechecking @@ -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)(hi)) +#define __clamp_t(type, val, lo, hi, uniq) \ + __clamp_once((type)(val), (type)(lo), (type)(hi), uniq) +#define clamp_t(type, val, lo, hi) __clamp_t(type, val, lo, hi, __COUNTER__) /** * clamp_val - return a value clamped to a given range using val's type