Patchwork sizeof doesn't always return long, it seems

login
register
about
Submitter Jens Rottmann
Date 2010-08-17 13:31:24
Message ID <4C6A8F2C.90706@LiPPERTEmbedded.de>
Download mbox | patch
Permalink /patch/1762/
State Accepted
Headers show

Comments

Jens Rottmann - 2010-08-17 13:31:24
coreboot: sizeof doesn't always return long, it seems

Correct for size_t would be %zx, but coreboot's printf doesn't support this.
Trying to keep it simple:  Two sizes are expected equal so use same %x for both.
Cast to unsigned int to make sure it fits.

Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
---

Hi Myles,

you have changed this from %x to %lx with rev 5603.  But my gcc 4.3.2 (32 bits)
appearently doesn't like it.  Maybe you have a 64 bit system?

If my approach is ok for you, would you please commit?

Thanks,
Jens
Myles Watson - 2010-08-17 16:33:56
On Tue, Aug 17, 2010 at 7:31 AM, Jens Rottmann
<JRottmann@lippertembedded.de> wrote:
> coreboot: sizeof doesn't always return long, it seems
>
> Correct for size_t would be %zx, but coreboot's printf doesn't support this.
> Trying to keep it simple:  Two sizes are expected equal so use same %x for both.
> Cast to unsigned int to make sure it fits.
>
> Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
Acked-by: Myles Watson <mylesgw@gmail.com>
Rev 5719.

Thanks,
Myles

Patch

--- src/arch/i386/boot/pirq_routing.c	(revision 5697)
+++ src/arch/i386/boot/pirq_routing.c	(working copy)
@@ -13,8 +13,8 @@ 
 	printk(BIOS_INFO, "Checking Interrupt Routing Table consistency...\n");
 
 	if (sizeof(struct irq_routing_table) != rt->size) {
-		printk(BIOS_WARNING, "Inconsistent Interrupt Routing Table size (0x%lx/0x%x).\n",
-			       sizeof(struct irq_routing_table),
+		printk(BIOS_WARNING, "Inconsistent Interrupt Routing Table size (0x%x/0x%x).\n",
+			       (unsigned int)sizeof(struct irq_routing_table),
 			       rt->size
 			);
 		rt->size=sizeof(struct irq_routing_table);