From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ADB832F1FF1; Mon, 22 Sep 2025 12:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544035; cv=none; b=E+xyKKL2QWE4rvi+6rs+mE8cQxpjezrR/pmRzUBy9uHZZGcDrXDwFz9o5dfrGzCfIvcw0YB5ZbSo5zzwVA9Ck/S+nhDjs5RUFcQqs3RuK6AiSynTcYbIauCIZS2EiQSXGKaN7qdbBJfEsF8RUyeAiuI8LjFiX++kaQR6bVXjnUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544035; c=relaxed/simple; bh=8nxZHKCLMp4/qRvAUZL6R06d+fkmiHSPK3idQXLV5q8=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=CfKWPb9HnJORkmnvB45p0GUvk14w67dE442kaQbAa5OqLf7L72x7+HDHHFFk4yHz8rg8qYgrPL8fBkjk9Ek54lGHEuwgTXAuYF9cP+4Flg2bo4sVpVFxFp5L5q4NReCuy87PQ5WlAadJmQx3OSJrRNp8Q9hyzHLt7RcvDtYUW0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rCD/wfgr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rCD/wfgr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87A58C4CEF7; Mon, 22 Sep 2025 12:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758544035; bh=8nxZHKCLMp4/qRvAUZL6R06d+fkmiHSPK3idQXLV5q8=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=rCD/wfgrmufPCvsNDRbJCFnkQa4h46LQuDrQ3AtmSp+TsD2tiSUM0m9xojEAt9dqR fQIZOeGsZE1Eit8tE738L/bcz6ZjHWhetEteI922CxzYh+tfLb0Irgb1MADTJ+HBPz M4yeDvKrXp6Zi6YpiXLJlgqQapTxZHznZwy4R0sw= Subject: Patch "minmax: don't use max() in situations that want a C constant expression" has been added to the 6.6-stable tree To: David.Laight@ACULAB.COM,David.Laight@aculab.com,Rodrigo.Siqueira@amd.com,Xinhui.Pan@amd.com,agk@redhat.com,airlied@gmail.com,akpm@linux-foundation.org,alexander.deucher@amd.com,alexandre.torgue@foss.st.com,amd-gfx@lists.freedesktop.org,andriy.shevchenko@linux.intel.com,anton.ivanov@cambridgegreys.com,arnd@kernel.org,artur.paszkiewicz@intel.com,bp@alien8.de,christian.koenig@amd.com,clm@fb.com,daniel@ffwll.ch,dave.hansen@linux.intel.com,davem@davemloft.net,dm-devel@lists.linux.dev,dmitry.torokhov@gmail.com,dri-devel@lists.freedesktop.org,dsahern@kernel.org,dsterba@suse.com,edumazet@google.com,evan.quan@amd.com,farbere@amazon.com,gregkh@linuxfoundation.org,harry.wentland@amd.com,hdegoede@redhat.com,hpa@zytor.com,ilpo.jarvinen@linux.intel.com,james.morse@arm.com,jdelvare@suse.com,jejb@linux.ibm.com,jernej.skrabec@gmail.com,joabreu@synopsys.com,johannes@sipsolutions.net,josef@toxicpanda.com,keescook@chromium.org,krzysztof.kozlowski@linaro.org,kuba@kernel.org,linus.walleij@linaro.org,linux-arm-kernel@lists.infradead.org,linux-mm@kvack.org,linux-staging@lists.linux.dev,linux-stm32@st-md-mailman.stormreply.com,linux-sunxi@lists.linux.dev,linux-um@lists.infradead.org,linux@rasmusvillemoes.dk,linux@roeck-us.net,lorenzo.stoakes@oracle.com,luc.vanoostenryck@gmail.com,luto@kernel.org,maarten.lankhorst@linux.intel.com,mailhol.vincent@wanadoo.fr,malattia@linux.it,markgross@kernel.org,martin.petersen@oracle.com,mchehab@kernel.org,mcoquelin.stm32@gmail.com,mhiramat@kernel.org,minchan@kernel.org,mingo@redhat.com,mkl@pengutronix.de,mripard@kernel.org,pabeni@redhat.com,peterz@infradead.org,pmladek@suse.com,qiuxu.zhuo@intel.com,richard@nod.at,rostedt@goodmis.org,rric@kernel.org,sakari.ailus@linux.intel.com,samuel@sholland.org,senozhatsky@chromium.org,shuah@kernel.org,snitzer@kernel.org,sunpeng.li@amd.com,tglx@linutronix.de,tony.luck@intel.com,torvalds@linux-foundation.org,tzimmermann@suse.de,wad@chromium.org,wens@csie.org,wg@grandegger.com,x86@kernel.org Cc: From: Date: Mon, 22 Sep 2025 14:26:59 +0200 In-Reply-To: <20250922103241.16213-7-farbere@amazon.com> Message-ID: <2025092259-viscosity-handoff-74f5@gregkh> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled minmax: don't use max() in situations that want a C constant expression to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: minmax-don-t-use-max-in-situations-that-want-a-c-constant-expression.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From linux-staging+bounces-34541-greg=kroah.com@lists.linux.dev Mon Sep 22 12:38:18 2025 From: Eliav Farber Date: Mon, 22 Sep 2025 10:32:32 +0000 Subject: minmax: don't use max() in situations that want a C constant expression To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Cc: Linus Torvalds , David Laight , Lorenzo Stoakes Message-ID: <20250922103241.16213-7-farbere@amazon.com> From: Linus Torvalds [ Upstream commit cb04e8b1d2f24c4c2c92f7b7529031fc35a16fed ] We only had a couple of array[] declarations, and changing them to just use 'MAX()' instead of 'max()' fixes the issue. This will allow us to simplify our min/max macros enormously, since they can now unconditionally use temporary variables to avoid using the argument values multiple times. Cc: David Laight Cc: Lorenzo Stoakes Signed-off-by: Linus Torvalds Signed-off-by: Eliav Farber Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +- drivers/input/touchscreen/cyttsp4_core.c | 2 +- drivers/irqchip/irq-sun6i-r.c | 2 +- drivers/net/can/usb/etas_es58x/es58x_devlink.c | 2 +- fs/btrfs/tree-checker.c | 2 +- lib/vsprintf.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) --- 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( 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(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)]; uint64_t feature_mask; int i, feature_index; uint32_t count = 0; --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -871,7 +871,7 @@ static void cyttsp4_get_mt_touches(struc 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(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++) { --- a/drivers/irqchip/irq-sun6i-r.c +++ b/drivers/irqchip/irq-sun6i-r.c @@ -270,7 +270,7 @@ static const struct irq_domain_ops sun6i static int sun6i_r_intc_suspend(void) { - u32 buf[BITS_TO_U32(max(SUN6I_NR_TOP_LEVEL_IRQS, SUN6I_NR_MUX_BITS))]; + u32 buf[BITS_TO_U32(MAX(SUN6I_NR_TOP_LEVEL_IRQS, SUN6I_NR_MUX_BITS))]; int i; /* Wake IRQs are enabled during system sleep and shutdown. */ --- 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 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(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; int ret = 0; if (es58x_sw_version_is_valid(fw_ver)) { --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -614,7 +614,7 @@ static int check_dir_item(struct extent_ */ 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(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1079,7 +1079,7 @@ char *resource_string(char *buf, char *e #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, + char sym[MAX(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; char *p = sym, *pend = sym + sizeof(sym); Patches currently in stable-queue which might be from farbere@amazon.com are queue-6.6/minmax-don-t-use-max-in-situations-that-want-a-c-constant-expression.patch queue-6.6/minmax-make-generic-min-and-max-macros-available-everywhere.patch queue-6.6/minmax-fix-up-min3-and-max3-too.patch queue-6.6/minmax-add-a-few-more-min_t-max_t-users.patch queue-6.6/minmax-improve-macro-expansion-and-type-checking.patch queue-6.6/minmax-avoid-overly-complicated-constant-expressions-in-vm-code.patch queue-6.6/minmax-simplify-min-max-clamp-implementation.patch queue-6.6/minmax-simplify-and-clarify-min_t-max_t-implementation.patch