Skip to contentSkip to conversation

IDE Debug compiler warnings

PATCH In review John Baboval 3 participants 3 messages Oct 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IDE Debug compiler warnings

This fixes up a few compiler warnings/errors when building with IDE_DEBUG or AHCI_DEBUG enabled.

---
 hw/ide/ahci.c |    2 +-
 hw/ide/pci.c  |    2 +-
 hw/ide/piix.c |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
hw/ide/ahci.c +1 -1
index 1c7e3a0..79277bb 100644
@@ -327,7 +327,7 @@ static void ahci_mem_write(void *opaque, target_phys_addr_t addr,
     }
      if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
-        DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val);
+        DPRINTF(-1, "(addr 0x%08X), val 0x%08lX\n", (unsigned) addr, val);
          switch (addr) {
             case HOST_CAP: /* R/WO, RO */
hw/ide/pci.c +1 -1
index f133c42..0d3f2f9 100644
@@ -335,7 +335,7 @@ static uint64_t bmdma_addr_read(void *opaque, target_phys_addr_t addr,
      data = (bm->addr >> (addr * 8)) & mask;
 #ifdef DEBUG_IDE
-    printf("%s: 0x%08x\n", __func__, (unsigned)*data);
+    printf("%s: 0x%08x\n", __func__, (unsigned)data);
 #endif
     return data;
 }
hw/ide/piix.c +2 -2
index 08cbbe2..3d71126 100644
@@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size)
         break;
     }
 #ifdef DEBUG_IDE
-    printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
+    printf("bmdma: readb 0x%02lx : 0x%02x\n", addr, val);
 #endif
     return val;
 }
@@ -68,7 +68,7 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr,
     }
  #ifdef DEBUG_IDE
-    printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
+    printf("bmdma: writeb 0x%02lx : 0x%02lx\n", addr, val);
 #endif
     switch(addr & 3) {
     case 0:
Signature · 1 line
1.7.4.1
#1 lore raw

hw/ide/ahci.c static void ahci_mem_write(void *opaque, · line 330

Quoted 8 lines · John Baboval
hw/ide/ahci.c +1 -1
@@ -327,7 +327,7 @@ static void ahci_mem_write(void *opaque,
 target_phys_addr_t addr,
     }
      if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
-        DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val);
+        DPRINTF(-1, "(addr 0x%08X), val 0x%08lX\n", (unsigned) addr, val);

val is uint64_t so you need to use PRIx64 (otherwise you get warnings on either 32 bit or 64 bit hosts depending on whether you use %x or %lx).

hw/ide/piix.c static uint64_t bmdma_read(void *opaque, · line 57

Quoted 9 lines
hw/ide/piix.c +1 -1
@@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque,
 target_phys_addr_t addr, unsigned size)
         break;
     }
  #ifdef DEBUG_IDE
-    printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
+    printf("bmdma: readb 0x%02lx : 0x%02x\n", addr, val);

target_phys_addr_t may be a type that %lx isn't correct for (depending on both the target and host architectures); you need to cast or use TARGET_FMT_plx here and in the next one.

-- PMM

#2 lore raw
Quoted 4 lines
Quoted 4 lines
hw/ide/ahci.c +0 -0
@@ -327,7 +327,7 @@ static void ahci_mem_write(void *opaque,
 target_phys_addr_t addr,
Quoted 8 lines

hw/ide/ahci.c static void ahci_mem_write(void *opaque, target_phys_addr_t addr, · line 329

Quoted 4 lines
hw/ide/ahci.c +1 -1
    }
     if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
-        DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val);
+        DPRINTF(-1, "(addr 0x%08X), val 0x%08lX\n", (unsigned) addr, val);

val is uint64_t so you need to use PRIx64 (otherwise you get warnings on either 32 bit or 64 bit hosts depending on whether you use %x or %lx).

This and other ahci format strings fixes are already in the queue: http://lists.nongnu.org/archive/html/qemu-devel/2011-10/msg03178.html

Thanks.
-- Max