Skip to contentSkip to conversation

two little build fixes

PATCH Superseded Gerd Hoffmann 4 participants 7 messages Aug 10, 2012 – Aug 13, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#5 lore raw

PATCH 2/2 scsi: fix warning

In reply to Gerd Hoffmann

hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in this function

Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5) are not clever enougth to figure, so sprinkle in a default: line to make them happy.

---
 hw/scsi-bus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/scsi-bus.c +2 -0
index b8a857d..4981a02 100644
@@ -761,6 +761,7 @@ static int ata_passthrough_12_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1:
@@ -784,6 +785,7 @@ static int ata_passthrough_16_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1:
Signature · 1 line
1.7.1
#0 lore raw

cover two little build fixes

Hi,

$subject says all.

cheers,
Gerd

Gerd Hoffmann (2):
avoid asprintf (not available on mingw)
scsi: fix warning

 hw/msix.c     |    5 ++---
 hw/scsi-bus.c |    2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/2 avoid asprintf (not available on mingw64)

---
 hw/msix.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
hw/msix.c +2 -3
index 800fc32..04345f2 100644
@@ -307,9 +307,8 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return -EINVAL;
     }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;
-    }
+    name = g_malloc(sizeof(dev->name) + 5);
+    snprintf(name, sizeof(dev->name) + 5, "%s-msix", dev->name);
 
     memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
 
Signature · 1 line
1.7.1
Acked-by on v1 2/2
#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] scsi: fix warning

In reply to Gerd Hoffmann

Il 10/08/2012 15:26, Gerd Hoffmann ha scritto:

Quoted 26 lines

hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in this function

Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5) are not clever enougth to figure, so sprinkle in a default: line to make them happy.

---
 hw/scsi-bus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/scsi-bus.c +1 -0
index b8a857d..4981a02 100644
@@ -761,6 +761,7 @@ static int ata_passthrough_12_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1:

hw/scsi-bus.c static int ata_passthrough_16_xfer_size(SCSIDevice *dev, uint8_t *buf) · line 791

Quoted 7 lines
hw/scsi-bus.c +1 -0
@@ -784,6 +785,7 @@ static int ata_passthrough_16_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1:

Paolo

#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] avoid asprintf (not available on mingw64)

In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann
---
 hw/msix.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
hw/msix.c +0 -0
index 800fc32..04345f2 100644

hw/msix.c int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, · line 313

Quoted 10 lines
hw/msix.c +2 -3
@@ -307,9 +307,8 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return -EINVAL;
     }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;
-    }
+    name = g_malloc(sizeof(dev->name) + 5);
+    snprintf(name, sizeof(dev->name) + 5, "%s-msix", dev->name);
 
     memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);

What about g_strdup_printf()?

#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] avoid asprintf (not available on mingw64)

Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Gerd Hoffmann
---
 hw/msix.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
hw/msix.c +2 -3
index 800fc32..04345f2 100644
@@ -307,9 +307,8 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return -EINVAL;
     }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;
-    }
+    name = g_malloc(sizeof(dev->name) + 5);
+    snprintf(name, sizeof(dev->name) + 5, "%s-msix", dev->name);
 
Quoted 3 lines

hw/msix.c int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, · line 313

Quoted 1 line
hw/msix.c +0 -0
     memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);

What about g_strdup_printf()?

+1

In either case, free() below needs to be changed to g_free().

#4 lore raw

Re: [Qemu-devel] [PATCH 1/2] avoid asprintf (not available on mingw64)

In reply to Markus Armbruster
Quoted 3 lines · Markus Armbruster
Quoted 1 line

- if (asprintf(&name, "%s-msix", dev->name) == -1) {

What about g_strdup_printf()?

Ah, nice. Didn't know glib has this.

cheers,
Gerd