From patchwork Sun Feb 25 16:54:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 206097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1658313dyb; Sun, 25 Feb 2024 08:55:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZHdAgeF3ibJEmullZLuFChvP3Do+B5ZxSBlD+pDd7fdyubDStx4PJmPWQ3Im0xeyZU3vrFK31BKbpNY6DvEpKNcgoaA== X-Google-Smtp-Source: AGHT+IGW8ip+hf7joXaAQMRrmNON3hkB5lsGMwX1huORFvC3GU09i60aKxTgE0F2VRkDUBPt5ezq X-Received: by 2002:ac2:4c49:0:b0:512:e704:44bc with SMTP id o9-20020ac24c49000000b00512e70444bcmr3756813lfk.23.1708880117040; Sun, 25 Feb 2024 08:55:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708880117; cv=pass; d=google.com; s=arc-20160816; b=aBXPw15NQznDcVGdDZLn0nbQQ7KszL9FxLL7oqCvhgJx0l55fLUxvuMjZtqe8Akbiz W4lpUwfx7skWRU4RUMAna+taAxajGURwkAueI3AvxcdgdpBIHBNxDgziCe6KcoNnN6KD G1GdEFyrTTrkbcDMl5TY9LuwgdemXtyT7VanjNqHS5McgcHv/eU/mMf/f1GlE2/9BnQO eYCY42mDuedOgP2vMoXm7kJvOsSjxlSk4v/Jv9b86l0yQ2LVzj+T9V9ST0vOZtPjO770 qN2N0zluDadqtc81/Pqf1yOSbgGGeXE0qO41DMcRAL+g0WW1JQNu9QBvXRoJtKfuMauX UJRA== 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=F98xCTVkzRhs/Efn8kmg+8jPcvt0XpdKh2Y2vrISD+w=; fh=nGE692sbVdRvha6RYbzMUXtm1nr/30sV7frdtDN2z14=; b=NAxZw0DD5h/wBiIvX2Pezryk9WEJ7z/HSk9xW/QfaDJiqrk7rdjv3S2KOlLsHX0QnR tCqEvcWzft2LXjj4W4BCIP4dCk+WfLoumNo/cSRi/TuvXUqRTyfsbzdEaBpePAQ2zaSm mSknykETc7Owe5qU3g5jOHgZyYqtrta/9uOp3Ag9gJZ/jo/qucaWNit+Uxp0TXcGREUA a/iqQaKknw+dIVn6c04LcKj1NaYp8Y6XrDwnfsMndd+MpWbKgkp22hbqitZPwFOYlecH eKsaFTAiiYogf7GHuEgQoxLMqejAIca1e3kqyNtFN5p1B2BK+7vU7drsdt5gZiVeq9g9 iQWw==; 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-80218-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80218-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ce22-20020a170906b25600b00a3ec216c61bsi1346998ejb.530.2024.02.25.08.55.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 08:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80218-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-80218-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80218-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 799D61F21CBA for ; Sun, 25 Feb 2024 16:55:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F2AA19BCA; Sun, 25 Feb 2024 16:54:53 +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 CD2921772D for ; Sun, 25 Feb 2024 16:54:49 +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=1708880091; cv=none; b=HIU+oeYCBUgc3y0AW2517QgVH87emhLQFDr/j5QPkfcAY1JvI0It+KYA3u0q6V/21UBRKEWVhAcNV5+tFUS+XTusQBFUmqlBg9Ef3U71ul9rysHyypxbgiWYrg9Wq67JVi4qOeOUqqgTxuKU16Ll8NlNEyMEmRfukTzbPv0JLFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708880091; c=relaxed/simple; bh=HYmYptU+uSUe8xvs+wnLG3Dq3f5gzj4spCQhIyLt2vM=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=THmyjjHSMMwF7ZNrs590mBr0xRhvXijOOLWONLLKsfDpTfHBq2h4NqFPn4euHG/thfCS/cb07hLhYlyvZ/IK/H0td1tjnHDZXAfbG+fS3YUSHabXUZyBv9DUKKqk79hYNCBEqTa9U//HUsyUe9B+qEB7b0lO60yNvvkOACEzxsQ= 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-102-MER6aJkKPaSjPChmSL3lxw-1; Sun, 25 Feb 2024 16:54:46 +0000 X-MC-Unique: MER6aJkKPaSjPChmSL3lxw-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:54:45 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 25 Feb 2024 16:54:45 +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 09/11] tree-wide: minmax: Replace all the uses of max() for array sizes with max_const() Thread-Topic: [PATCH next v2 09/11] tree-wide: minmax: Replace all the uses of max() for array sizes with max_const() Thread-Index: AdpoC1PeUhR3U90kTRae/PLire4h2g== Date: Sun, 25 Feb 2024 16:54:45 +0000 Message-ID: <346b7e12ee6d4f728bcdb7d15ea1ee52@AcuMS.aculab.com> 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: 1791890677606666457 X-GMAIL-MSGID: 1791890677606666457 These are the only uses of max() that require a constant value from constant parameters. There don't seem to be any similar uses of min(). Replacing the max() by max_const() lets min()/max() be simplified speeding up compilation. max_const() will convert enums to int (or unsigned int) so that the casts added by max_t() are no longer needed. Signed-off-by: David Laight --- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +- drivers/gpu/drm/drm_color_mgmt.c | 4 ++-- drivers/input/touchscreen/cyttsp4_core.c | 2 +- drivers/net/can/usb/etas_es58x/es58x_devlink.c | 2 +- fs/btrfs/tree-checker.c | 2 +- lib/vsprintf.c | 4 ++-- net/ipv4/proc.c | 2 +- net/ipv6/proc.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) Changes for v2: - Typographical and spelling corrections to the commit messages. Patches unchanged. diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c index 00cd615bbcdc..935fb4014f7c 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c @@ -708,7 +708,7 @@ static const char *smu_get_feature_name(struct smu_context *smu, size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu, char *buf) { - int8_t sort_feature[max(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)]; + int8_t sort_feature[max_const(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)]; uint64_t feature_mask; int i, feature_index; uint32_t count = 0; diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index d021497841b8..43a6bd0ca960 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -532,8 +532,8 @@ int drm_plane_create_color_properties(struct drm_plane *plane, { struct drm_device *dev = plane->dev; struct drm_property *prop; - struct drm_prop_enum_list enum_list[max_t(int, DRM_COLOR_ENCODING_MAX, - DRM_COLOR_RANGE_MAX)]; + struct drm_prop_enum_list enum_list[max_const(DRM_COLOR_ENCODING_MAX, + DRM_COLOR_RANGE_MAX)]; int i, len; if (WARN_ON(supported_encodings == 0 || diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 7cb26929dc73..c6884c3c3fca 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -871,7 +871,7 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch) struct cyttsp4_touch tch; int sig; int i, j, t = 0; - int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; + int ids[max_const(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int)); for (i = 0; i < num_cur_tch; i++) { diff --git a/drivers/net/can/usb/etas_es58x/es58x_devlink.c b/drivers/net/can/usb/etas_es58x/es58x_devlink.c index 635edeb8f68c..28fa87668bf8 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_devlink.c +++ b/drivers/net/can/usb/etas_es58x/es58x_devlink.c @@ -215,7 +215,7 @@ static int es58x_devlink_info_get(struct devlink *devlink, struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version; struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version; struct es58x_hw_revision *hw_rev = &es58x_dev->hardware_revision; - char buf[max(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; + char buf[max_const(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; int ret = 0; if (es58x_sw_version_is_valid(fw_ver)) { diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index 6eccf8496486..aec4729a9a82 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -615,7 +615,7 @@ static int check_dir_item(struct extent_buffer *leaf, */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + char namebuf[max_const(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 552738f14275..6c3c319afd86 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1080,8 +1080,8 @@ char *resource_string(char *buf, char *end, struct resource *res, #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") - char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, - 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; + char sym[max_const(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, + 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; char *p = sym, *pend = sym + sizeof(sym); int decode = (fmt[0] == 'R') ? 1 : 0; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 5f4654ebff48..a4aff27f949b 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -43,7 +43,7 @@ #include #include -#define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) +#define TCPUDP_MIB_MAX max_const(UDP_MIB_MAX, TCP_MIB_MAX) /* * Report socket allocation statistics [mea@utu.fi] diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 6d1d9221649d..7fedb60aaeac 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -27,7 +27,7 @@ #include #define MAX4(a, b, c, d) \ - max_t(u32, max_t(u32, a, b), max_t(u32, c, d)) + max_const(max_const(a, b), max_const(c, d)) #define SNMP_MIB_MAX MAX4(UDP_MIB_MAX, TCP_MIB_MAX, \ IPSTATS_MIB_MAX, ICMP_MIB_MAX)