Skip to contentSkip to conversation

irqchip: gicv3-its: fix use of max with decimal constant

PATCH New Will Deacon 3 participants 3 messages Dec 17, 2014 – Jan 7, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip: gicv3-its: fix use of max with decimal constant

arm64 defconfig spits out the following compiler warning from the ITS driver:

In file included from include/linux/bitmap.h:9:0,

                 from drivers/irqchip/irq-gic-v3-its.c:18:
drivers/irqchip/irq-gic-v3-its.c: In function ?its_create_device?:
include/linux/kernel.h:716:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_max1 == &_max2);  \
                 ^

drivers/irqchip/irq-gic-v3-its.c:1056:12: note: in expansion of macro ?max?
nr_ites = max(2, roundup_pow_of_two(nvecs));

Fix the warning by specifying the decimal constant `2' explicitly as an unsigned long type.

---
 drivers/irqchip/irq-gic-v3-its.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
index 86e4684adeb1..d8996bdf0f61 100644
@@ -1053,7 +1053,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
 	 * of two entries. No, the architecture doesn't let you
 	 * express an ITT with a single entry.
 	 */
-	nr_ites = max(2, roundup_pow_of_two(nvecs));
+	nr_ites = max(2UL, roundup_pow_of_two(nvecs));
 	sz = nr_ites * its->ite_size;
 	sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
 	itt = kmalloc(sz, GFP_KERNEL);
Signature · 1 line
2.1.3
#1 lore raw

PATCH 1/1 irqchip: gicv3-its: fix use of max with decimal constant

Hi Will,

Quoted 27 lines · Will Deacon

arm64 defconfig spits out the following compiler warning from the ITS driver:

In file included from include/linux/bitmap.h:9:0,

                 from drivers/irqchip/irq-gic-v3-its.c:18:
drivers/irqchip/irq-gic-v3-its.c: In function ?its_create_device?:
include/linux/kernel.h:716:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_max1 == &_max2);  \
                 ^

drivers/irqchip/irq-gic-v3-its.c:1056:12: note: in expansion of macro ?max?
nr_ites = max(2, roundup_pow_of_two(nvecs));

Fix the warning by specifying the decimal constant `2' explicitly as an unsigned long type.

---
 drivers/irqchip/irq-gic-v3-its.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +0 -0
index 86e4684adeb1..d8996bdf0f61 100644

drivers/irqchip/irq-gic-v3-its.c static struct its_device *its_create_device(struct its_node *its, u32 dev_id, · line 1059

Quoted 8 lines
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -1053,7 +1053,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
 	 * of two entries. No, the architecture doesn't let you
 	 * express an ITT with a single entry.
 	 */
-	nr_ites = max(2, roundup_pow_of_two(nvecs));
+	nr_ites = max(2UL, roundup_pow_of_two(nvecs));
 	sz = nr_ites * its->ite_size;
 	sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
 	itt = kmalloc(sz, GFP_KERNEL);

Well spotted, thanks.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Applied
#2 lore raw

PATCH 1/1 irqchip: gicv3-its: fix use of max with decimal constant

In reply to Will Deacon
Quoted 12 lines · Will Deacon

arm64 defconfig spits out the following compiler warning from the ITS driver:

In file included from include/linux/bitmap.h:9:0,

                 from drivers/irqchip/irq-gic-v3-its.c:18:
drivers/irqchip/irq-gic-v3-its.c: In function ?its_create_device?:
include/linux/kernel.h:716:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_max1 == &_max2);  \
                 ^

drivers/irqchip/irq-gic-v3-its.c:1056:12: note: in expansion of macro ?max?
nr_ites = max(2, roundup_pow_of_two(nvecs));

Quoted 8 lines

Fix the warning by specifying the decimal constant `2' explicitly as an unsigned long type.

---
 drivers/irqchip/irq-gic-v3-its.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to irqchip/urgent with Marc's Ack.

thx,

Jason.