Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

minmax: don't use max() in situations that want a C constant expression

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>

+6 -6
+1 -1
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
··· 794 794 size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu, 795 795 char *buf) 796 796 { 797 - int8_t sort_feature[max(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)]; 797 + int8_t sort_feature[MAX(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)]; 798 798 uint64_t feature_mask; 799 799 int i, feature_index; 800 800 uint32_t count = 0;
+1 -1
drivers/input/touchscreen/cyttsp4_core.c
··· 871 871 struct cyttsp4_touch tch; 872 872 int sig; 873 873 int i, j, t = 0; 874 - int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; 874 + int ids[MAX(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; 875 875 876 876 memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int)); 877 877 for (i = 0; i < num_cur_tch; i++) {
+1 -1
drivers/irqchip/irq-sun6i-r.c
··· 270 270 271 271 static int sun6i_r_intc_suspend(void) 272 272 { 273 - u32 buf[BITS_TO_U32(max(SUN6I_NR_TOP_LEVEL_IRQS, SUN6I_NR_MUX_BITS))]; 273 + u32 buf[BITS_TO_U32(MAX(SUN6I_NR_TOP_LEVEL_IRQS, SUN6I_NR_MUX_BITS))]; 274 274 int i; 275 275 276 276 /* Wake IRQs are enabled during system sleep and shutdown. */
+1 -1
drivers/net/can/usb/etas_es58x/es58x_devlink.c
··· 215 215 struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version; 216 216 struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version; 217 217 struct es58x_hw_revision *hw_rev = &es58x_dev->hardware_revision; 218 - char buf[max(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; 218 + char buf[MAX(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; 219 219 int ret = 0; 220 220 221 221 if (es58x_sw_version_is_valid(fw_ver)) {
+1 -1
fs/btrfs/tree-checker.c
··· 634 634 */ 635 635 if (key->type == BTRFS_DIR_ITEM_KEY || 636 636 key->type == BTRFS_XATTR_ITEM_KEY) { 637 - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; 637 + char namebuf[MAX(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; 638 638 639 639 read_extent_buffer(leaf, namebuf, 640 640 (unsigned long)(di + 1), name_len);
+1 -1
lib/vsprintf.c
··· 1080 1080 #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) 1081 1081 #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") 1082 1082 #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") 1083 - char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, 1083 + char sym[MAX(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, 1084 1084 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; 1085 1085 1086 1086 char *p = sym, *pend = sym + sizeof(sym);