]> 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>
Wed, 8 Oct 2025 15:29:34 +0000 (15:29 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:21:52 +0000 (16:21 +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/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 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 4cd3e533740bf7669f38c1e66a57f6f89b3b9f07..74b1bd3314253e3798b77be5fa22244e32852f89 100644 (file)
@@ -268,7 +268,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 26efba6bcee804a1bbec0ffdc6544d8098f0a896..43d47ba8dabcae66182fded1f2cce3db959037a6 100644 (file)
@@ -1705,7 +1705,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 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 sectors_to_process;
 
index 51e04efe3e202cdf524ae846e3c9b8206a72c8a8..8f96ddaceb9a74e651263f652635885eaa0a756e 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 d86abdc77c26feda832c34a097abbd4f35ec1cc3..e46eb93c115ddbd2b60363b4bf50f1d1a1cb1356 100644 (file)
@@ -1100,7 +1100,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);