Skip to contentSkip to conversation

Coccinelle cleanups

PATCH In review Philippe Mathieu-Daudé 3 participants 11 messages Jul 5, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover Coccinelle cleanups

Hi Michael,

Nothing exciting here, patches created mechanically (common after soft freeze).

All patches are reviewed, can you queue them in your Trivial tree?

Thanks,

Phil.

Since v1:
- rebased
- dropped incorrect "crypto: Remove useless casts" (Daniel)
- use PCI_DEVICE() to access XenPCIPassthroughState->dev (Peter)
- added R-b, A-b

Philippe Mathieu-Daudé (7):
qobject: Catch another straggler for use of qdict_put_str()
error: Remove NULL checks on error_propagate() calls
xen: Use the PCI_DEVICE macro
tests/bios-tables-test: Remove an useless cast
ui/vnc: Remove useless parenthesis around DIV_ROUND_UP macro hw/pci-host: Remove useless parenthesis around DIV_ROUND_UP macro hw/intc/gicv3: Remove useless parenthesis around DIV_ROUND_UP macro

 include/hw/intc/arm_gicv3_common.h | 2 +-
 hw/pci-host/piix.c                 | 2 +-
 hw/pci-host/q35.c                  | 2 +-
 hw/s390x/virtio-ccw.c              | 4 +---
 hw/xen/xen_pt_config_init.c        | 8 ++++----
 qobject/block-qdict.c              | 2 +-
 tests/bios-tables-test.c           | 2 +-
 ui/vnc-enc-tight.c                 | 2 +-
 ui/vnc.c                           | 3 ++-
 9 files changed, 13 insertions(+), 14 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/7 qobject: Catch another straggler for use of qdict_put_str()

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/qobject.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 qobject/block-qdict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qobject/block-qdict.c +1 -1
index 80c653013f..ae363708ab 100644
@@ -572,7 +572,7 @@ static QObject *qdict_crumple_for_keyval_qiv(QDict *src, Error **errp)
         if (!tmp) {
             tmp = qdict_clone_shallow(src);
         }
-        qdict_put(tmp, ent->key, qstring_from_str(s));
+        qdict_put_str(tmp, ent->key, s);
         g_free(buf);
     }
 
Signature · 1 line
2.18.0
#2 lore raw

PATCH v2 2/7 error: Remove NULL checks on error_propagate() calls

In reply to Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 hw/s390x/virtio-ccw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/s390x/virtio-ccw.c +1 -3
index b92a85d0b0..7ddb378d52 100644
@@ -1836,11 +1836,9 @@ static void vhost_vsock_ccw_realize(VirtioCcwDevice *ccw_dev, Error **errp)
 {
     VHostVSockCCWState *dev = VHOST_VSOCK_CCW(ccw_dev);
     DeviceState *vdev = DEVICE(&dev->vdev);
-    Error *err = NULL;
 
     qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
-    object_property_set_bool(OBJECT(vdev), true, "realized", &err);
-    error_propagate(errp, err);
+    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
 }
 
 static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data)
Signature · 1 line
2.18.0
Reviewed-by on v2 2/7
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/7] error: Remove NULL checks on error_propagate() calls

Quoted 6 lines · On Thu, 5 Jul 2018 12:58:06 -0300 Philippe Mathieu-Daudé <[email protected]>…

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
Quoted 7 lines
---
 hw/s390x/virtio-ccw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

I might send this via the s390x tree; in case trivial is quicker:

#4 lore raw

PATCH v2 3/7 xen: Use the PCI_DEVICE macro

In reply to Philippe Mathieu-Daudé

TYPE_XEN_PT_DEVICE is a subclass of TYPE_PCI_DEVICE, the clean way to access the PCIDevice pointer is using the PCI_DEVICE() macro.

---
 hw/xen/xen_pt_config_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_pt_config_init.c +4 -4
index aee31c62bb..47f9010c75 100644
@@ -358,7 +358,7 @@ static uint64_t xen_pt_get_bar_size(PCIIORegion *r)
 static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
                                          int index)
 {
-    PCIDevice *d = &s->dev;
+    PCIDevice *d = PCI_DEVICE(s);
     XenPTRegion *region = NULL;
     PCIIORegion *r;
 
@@ -469,7 +469,7 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
 {
     XenPTRegInfo *reg = cfg_entry->reg;
     XenPTRegion *base = NULL;
-    PCIDevice *d = &s->dev;
+    PCIDevice *d = PCI_DEVICE(s);
     const PCIIORegion *r;
     uint32_t writable_mask = 0;
     uint32_t bar_emu_mask = 0;
@@ -543,7 +543,7 @@ static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
 {
     XenPTRegInfo *reg = cfg_entry->reg;
     XenPTRegion *base = NULL;
-    PCIDevice *d = (PCIDevice *)&s->dev;
+    PCIDevice *d = PCI_DEVICE(s);
     uint32_t writable_mask = 0;
     uint32_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
     pcibus_t r_size = 0;
@@ -1587,7 +1587,7 @@ static int xen_pt_pcie_size_init(XenPCIPassthroughState *s,
                                  const XenPTRegGroupInfo *grp_reg,
                                  uint32_t base_offset, uint8_t *size)
 {
-    PCIDevice *d = &s->dev;
+    PCIDevice *d = PCI_DEVICE(s);
     uint8_t version = get_capability_version(s, base_offset);
     uint8_t type = get_device_type(s, base_offset);
     uint8_t pcie_size = 0;
Signature · 7 lines
2.18.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH v2 4/7 tests/bios-tables-test: Remove an useless cast

In reply to Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/typecast.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 tests/bios-tables-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/bios-tables-test.c +1 -1
index 4e24930c4b..c1ad1b3470 100644
@@ -319,7 +319,7 @@ static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
     ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
     g_assert_no_error(error);
     if (ret) {
-        ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
+        ret = g_file_get_contents(sdt->asl_file, &sdt->asl,
                                   &sdt->asl_len, &error);
         g_assert(ret);
         g_assert_no_error(error);
Signature · 1 line
2.18.0
#6 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] tests/bios-tables-test: Remove an useless cast

Quoted 1 line · Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

In the subject: s/an useless/a useless/

(English is weird; we use "a" when the 'u' is pronounced hard as in "unicorn", and "an" when the 'u' is soft as in "umbrella")

Quoted 9 lines
   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
             --macro-file scripts/cocci-macro-file.h \
             --dir . --in-place

---

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] tests/bios-tables-test: Remove an useless cast

Quoted 7 lines · Eric Blake
Quoted 1 line · Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

In the subject: s/an useless/a useless/

(English is weird; we use "a" when the 'u' is pronounced hard as in "unicorn", and "an" when the 'u' is soft as in "umbrella")

TIL, thanks for catching/correcting this Eric :)

Quoted 9 lines
Quoted 9 lines

   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
             --macro-file scripts/cocci-macro-file.h \
             --dir . --in-place

---

#8 lore raw

PATCH v2 5/7 ui/vnc: Remove useless parenthesis around DIV_ROUND_UP macro

In reply to Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/round.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 ui/vnc-enc-tight.c | 2 +-
 ui/vnc.c           | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
ui/vnc-enc-tight.c +1 -1
index f38aceb4da..0b4a5ac71f 100644
@@ -979,7 +979,7 @@ static int send_mono_rect(VncState *vs, int x, int y,
     }
 #endif
 
-    bytes = (DIV_ROUND_UP(w, 8)) * h;
+    bytes = DIV_ROUND_UP(w, 8) * h;
 
     vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
     vnc_write_u8(vs, VNC_TIGHT_FILTER_PALETTE);
ui/vnc.c +2 -1
index 359693238b..3361432a51 100644
@@ -2967,7 +2967,8 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
             PIXMAN_FORMAT_BPP(pixman_image_get_format(vd->guest.fb));
         guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);
         guest_stride = pixman_image_get_stride(vd->guest.fb);
-        guest_ll = pixman_image_get_width(vd->guest.fb) * (DIV_ROUND_UP(guest_bpp, 8));
+        guest_ll = pixman_image_get_width(vd->guest.fb)
+                   * DIV_ROUND_UP(guest_bpp, 8);
     }
     line_bytes = MIN(server_stride, guest_ll);
 
Signature · 1 line
2.18.0
#9 lore raw

PATCH v2 6/7 hw/pci-host: Remove useless parenthesis around DIV_ROUND_UP macro

In reply to Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/round.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 hw/pci-host/piix.c | 2 +-
 hw/pci-host/q35.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/piix.c +1 -1
index 0e608347c1..317c0feca6 100644
@@ -144,7 +144,7 @@ static void i440fx_update_memory_mappings(PCII440FXState *d)
     memory_region_transaction_begin();
     for (i = 0; i < 13; i++) {
         pam_update(&d->pam_regions[i], i,
-                   pd->config[I440FX_PAM + (DIV_ROUND_UP(i, 2))]);
+                   pd->config[I440FX_PAM + DIV_ROUND_UP(i, 2)]);
     }
     memory_region_set_enabled(&d->smram_region,
                               !(pd->config[I440FX_SMRAM] & SMRAM_D_OPEN));
hw/pci-host/q35.c +1 -1
index 02f9576588..b3a5b3036d 100644
@@ -352,7 +352,7 @@ static void mch_update_pam(MCHPCIState *mch)
     memory_region_transaction_begin();
     for (i = 0; i < 13; i++) {
         pam_update(&mch->pam_regions[i], i,
-                   pd->config[MCH_HOST_BRIDGE_PAM0 + (DIV_ROUND_UP(i, 2))]);
+                   pd->config[MCH_HOST_BRIDGE_PAM0 + DIV_ROUND_UP(i, 2)]);
     }
     memory_region_transaction_commit();
 }
Signature · 1 line
2.18.0
#10 lore raw

PATCH v2 7/7 hw/intc/gicv3: Remove useless parenthesis around DIV_ROUND_UP macro

In reply to Philippe Mathieu-Daudé

Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/round.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place
---
 include/hw/intc/arm_gicv3_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/intc/arm_gicv3_common.h +1 -1
index b798486ecf..31ec9a1ae4 100644
@@ -62,7 +62,7 @@
  * avoids bugs where we forget to subtract GIC_INTERNAL from an
  * interrupt number.
  */
-#define GICV3_BMP_SIZE (DIV_ROUND_UP(GICV3_MAXIRQ, 32))
+#define GICV3_BMP_SIZE DIV_ROUND_UP(GICV3_MAXIRQ, 32)
 
 #define GIC_DECLARE_BITMAP(name) \
     uint32_t name[GICV3_BMP_SIZE]
Signature · 1 line
2.18.0