From 5325cc34a2ca985283134c7e264be7851b112d4e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 7 Jul 2020 18:05:54 +0200 Subject: qom: Put name parameter before value / visitor parameter The object_property_set_FOO() setters take property name and value in an unusual order: void object_property_set_FOO(Object *obj, FOO_TYPE value, const char *name, Error **errp) Having to pass value before name feels grating. Swap them. Same for object_property_set(), object_property_get(), and object_property_parse(). Convert callers with this Coccinelle script: @@ identifier fun = { object_property_get, object_property_parse, object_property_set_str, object_property_set_link, object_property_set_bool, object_property_set_int, object_property_set_uint, object_property_set, object_property_set_qobject }; expression obj, v, name, errp; @@ - fun(obj, v, name, errp) + fun(obj, name, v, errp) Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error message "no position information". Convert that one manually. Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by ARMSSE being used both as typedef and function-like macro there. Convert manually. Fails to convert hw/rx/rx-gdbsim.c, because Coccinelle gets confused by RXCPU being used both as typedef and function-like macro there. Convert manually. The other files using RXCPU that way don't need conversion. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200707160613.848843-27-armbru@redhat.com> [Straightforwad conflict with commit 2336172d9b "audio: set default value for pcspk.iobase property" resolved] --- hw/s390x/ipl.c | 4 ++-- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/s390-skeys.c | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/s390x/s390-virtio-ccw.c | 6 +++--- hw/s390x/virtio-ccw-crypto.c | 5 ++--- hw/s390x/virtio-ccw-rng.c | 3 +-- 7 files changed, 11 insertions(+), 13 deletions(-) (limited to 'hw/s390x') diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index ce21494..7c893e5 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -555,9 +555,9 @@ static void update_machine_ipl_properties(IplParameterBlock *iplb) ascii_loadparm[i] = ebcdic2ascii[(uint8_t) ebcdic_loadparm[i]]; } ascii_loadparm[i] = 0; - object_property_set_str(machine, ascii_loadparm, "loadparm", &err); + object_property_set_str(machine, "loadparm", ascii_loadparm, &err); } else { - object_property_set_str(machine, "", "loadparm", &err); + object_property_set_str(machine, "loadparm", "", &err); } if (err) { warn_report_err(err); diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 1e4537f..a7b2a15 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -824,7 +824,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s, return NULL; } - object_property_set_str(OBJECT(dev), target, "target", &local_err); + object_property_set_str(OBJECT(dev), "target", target, &local_err); if (local_err) { object_unparent(OBJECT(dev)); error_propagate_prepend(errp, local_err, diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 1e036cc..db2f49c 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -401,7 +401,7 @@ static void s390_skeys_instance_init(Object *obj) object_property_add_bool(obj, "migration-enabled", s390_skeys_get_migration_enabled, s390_skeys_set_migration_enabled); - object_property_set_bool(obj, true, "migration-enabled", NULL); + object_property_set_bool(obj, "migration-enabled", true, NULL); } static void s390_skeys_class_init(ObjectClass *oc, void *data) diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index 0144b90..4441e1d 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -388,7 +388,7 @@ static void s390_stattrib_instance_init(Object *obj) object_property_add_bool(obj, "migration-enabled", s390_stattrib_get_migration_enabled, s390_stattrib_set_migration_enabled); - object_property_set_bool(obj, true, "migration-enabled", NULL); + object_property_set_bool(obj, "migration-enabled", true, NULL); sas->migration_cur_gfn = 0; } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 023fd25..07609a9 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -70,7 +70,7 @@ static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, S390CPU *cpu = S390_CPU(object_new(typename)); Error *err = NULL; - object_property_set_int(OBJECT(cpu), core_id, "core-id", &err); + object_property_set_int(OBJECT(cpu), "core-id", core_id, &err); if (err != NULL) { goto out; } @@ -736,14 +736,14 @@ static inline void s390_machine_initfn(Object *obj) machine_set_aes_key_wrap); object_property_set_description(obj, "aes-key-wrap", "enable/disable AES key wrapping using the CPACF wrapping key"); - object_property_set_bool(obj, true, "aes-key-wrap", NULL); + object_property_set_bool(obj, "aes-key-wrap", true, NULL); object_property_add_bool(obj, "dea-key-wrap", machine_get_dea_key_wrap, machine_set_dea_key_wrap); object_property_set_description(obj, "dea-key-wrap", "enable/disable DEA key wrapping using the CPACF wrapping key"); - object_property_set_bool(obj, true, "dea-key-wrap", NULL); + object_property_set_bool(obj, "dea-key-wrap", true, NULL); object_property_add_str(obj, "loadparm", machine_get_loadparm, machine_set_loadparm); object_property_set_description(obj, "loadparm", diff --git a/hw/s390x/virtio-ccw-crypto.c b/hw/s390x/virtio-ccw-crypto.c index 36cfdf8..5720e84 100644 --- a/hw/s390x/virtio-ccw-crypto.c +++ b/hw/s390x/virtio-ccw-crypto.c @@ -26,9 +26,8 @@ static void virtio_ccw_crypto_realize(VirtioCcwDevice *ccw_dev, Error **errp) return; } - object_property_set_link(OBJECT(vdev), - OBJECT(dev->vdev.conf.cryptodev), "cryptodev", - NULL); + object_property_set_link(OBJECT(vdev), "cryptodev", + OBJECT(dev->vdev.conf.cryptodev), NULL); } static void virtio_ccw_crypto_instance_init(Object *obj) diff --git a/hw/s390x/virtio-ccw-rng.c b/hw/s390x/virtio-ccw-rng.c index 513f85a..8cf01ce 100644 --- a/hw/s390x/virtio-ccw-rng.c +++ b/hw/s390x/virtio-ccw-rng.c @@ -27,8 +27,7 @@ static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp) return; } - object_property_set_link(OBJECT(dev), - OBJECT(dev->vdev.conf.rng), "rng", + object_property_set_link(OBJECT(dev), "rng", OBJECT(dev->vdev.conf.rng), NULL); } -- cgit v1.1