Skip to content

Commit cb04e8b

Browse files
committed
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 <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9f499b8 commit cb04e8b

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ static const char *smu_get_feature_name(struct smu_context *smu,
794794
size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu,
795795
char *buf)
796796
{
797-
int8_t sort_feature[max(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)];
797+
int8_t sort_feature[MAX(SMU_FEATURE_COUNT, SMU_FEATURE_MAX)];
798798
uint64_t feature_mask;
799799
int i, feature_index;
800800
uint32_t count = 0;

drivers/input/touchscreen/cyttsp4_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch)
871871
struct cyttsp4_touch tch;
872872
int sig;
873873
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)];
875875

876876
memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int));
877877
for (i = 0; i < num_cur_tch; i++) {

drivers/irqchip/irq-sun6i-r.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static const struct irq_domain_ops sun6i_r_intc_domain_ops = {
270270

271271
static int sun6i_r_intc_suspend(void)
272272
{
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))];
274274
int i;
275275

276276
/* Wake IRQs are enabled during system sleep and shutdown. */

drivers/net/can/usb/etas_es58x/es58x_devlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int es58x_devlink_info_get(struct devlink *devlink,
215215
struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version;
216216
struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version;
217217
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"))];
219219
int ret = 0;
220220

221221
if (es58x_sw_version_is_valid(fw_ver)) {

fs/btrfs/tree-checker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ static int check_dir_item(struct extent_buffer *leaf,
634634
*/
635635
if (key->type == BTRFS_DIR_ITEM_KEY ||
636636
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)];
638638

639639
read_extent_buffer(leaf, namebuf,
640640
(unsigned long)(di + 1), name_len);

lib/vsprintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ char *resource_string(char *buf, char *end, struct resource *res,
10801080
#define FLAG_BUF_SIZE (2 * sizeof(res->flags))
10811081
#define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]")
10821082
#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,
10841084
2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)];
10851085

10861086
char *p = sym, *pend = sym + sizeof(sym);

0 commit comments

Comments
 (0)