]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
minmax: don't use max() in situations that want a C constant expression
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 Oct 2025 12:15:10 +0000 (12:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:21 +0000 (11:56 +0200)
[ 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 <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
drivers/input/touchscreen/cyttsp4_core.c
drivers/irqchip/irq-sun6i-r.c
drivers/md/dm-integrity.c
fs/btrfs/tree-checker.c
lib/vsprintf.c

index 768b6e7dbd7719680485b33104164d73be8f7520..fd1faa840ec09a19605e69b0a2550c611381c168 100644 (file)
@@ -700,7 +700,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(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)];
        uint64_t feature_mask;
        int i, feature_index;
        uint32_t count = 0;
index dccbcb942fe59affc47488e83343a9b9cec576e7..936d69da3bda430469dedba2adaeebf164135c08 100644 (file)
@@ -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(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++) {
index a01e440494154ecbf93e07a0fcb5f052ecb478a9..99958d470d6268cb5654a333b34eeb31e7ec37fc 100644 (file)
@@ -270,7 +270,7 @@ static const struct irq_domain_ops sun6i_r_intc_domain_ops = {
 
 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. */
index a201019babe40b8f48bdb2121441b8a1932afba2..fc9cb626ca917aa0433c3a34928d8fb4ac572da9 100644 (file)
@@ -1794,7 +1794,7 @@ static void integrity_metadata(struct work_struct *w)
                struct bio *bio = dm_bio_from_per_bio_data(dio, sizeof(struct dm_integrity_io));
                char *checksums;
                unsigned int extra_space = unlikely(digest_size > ic->tag_size) ? digest_size - ic->tag_size : 0;
-               char checksums_onstack[max((size_t)HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)];
+               char checksums_onstack[MAX(HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)];
                sector_t sector;
                unsigned int sectors_to_process;
 
index d3e5429ee03d2e28188e703d4dbf331eba2aa306..6108cfab1ba5935fa5c3cd40c4607959c18103b8 100644 (file)
@@ -608,7 +608,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(BTRFS_NAME_LEN, XATTR_NAME_MAX)];
 
                        read_extent_buffer(leaf, namebuf,
                                        (unsigned long)(di + 1), name_len);
index fa1c197018551711ab1ffa55df20b6dc3847d190..2b0b5f08b8fc0b415f4d71916d300e26a670f18a 100644 (file)
@@ -1082,7 +1082,7 @@ 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,
+       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);