Skip to contentSkip to conversation

two little build fixes

PATCH Applied Gerd Hoffmann 3 participants 5 messages Aug 13, 2012 – Aug 18, 2012

lore
Share & tools
lore
#0 lore raw

v2 cover two little build fixes

Hi,

Patch #1 uses g_strdup_printf now, #2 is unchanged.

cheers,
Gerd

Gerd Hoffmann (2):
Avoid asprintf() which is not available on mingw
scsi: fix warning

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

PATCH v2 1/2 Avoid asprintf() which is not available on mingw

Use g_strdup_printf() instead.

---
 hw/msix.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
hw/msix.c +2 -6
index 800fc32..aea340b 100644
@@ -307,13 +307,9 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
         return -EINVAL;
     }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;
-    }
-
+    name = g_strdup_printf("%s-msix", dev->name);
     memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
-
-    free(name);
+    g_free(name);
 
     ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
                     MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,
Signature · 1 line
1.7.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] Avoid asprintf() which is not available on mingw

Am 13.08.2012 13:05, schrieb Gerd Hoffmann:

Quoted 17 lines

Use g_strdup_printf() instead.

---
  hw/msix.c |    8 ++------
  1 files changed, 2 insertions(+), 6 deletions(-)
hw/msix.c +0 -2
index 800fc32..aea340b 100644
@@ -307,13 +307,9 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
          return -EINVAL;
      }
 
-    if (asprintf(&name, "%s-msix", dev->name) == -1) {
-        return -ENOMEM;

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

Quoted 10 lines
hw/msix.c +2 -4
-    }
-
+    name = g_strdup_printf("%s-msix", dev->name);
      memory_region_init(&dev->msix_exclusive_bar, name, MSIX_EXCLUSIVE_BAR_SIZE);
-
-    free(name);
+    g_free(name);
 
      ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
                      MSIX_EXCLUSIVE_BAR_TABLE_OFFSET, &dev->msix_exclusive_bar,
#3 lore raw

PATCH v2 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
Applied
#4 lore raw
In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Hi,

Patch #1 uses g_strdup_printf now, #2 is unchanged.

Thanks, applied both.

Quoted 13 lines

cheers,
Gerd

Gerd Hoffmann (2):
Avoid asprintf() which is not available on mingw
scsi: fix warning

 hw/msix.c     |    8 ++------
 hw/scsi-bus.c |    2 ++
 2 files changed, 4 insertions(+), 6 deletions(-)