error: prepare for auto propagated local_err
Subsystems (2)
v7 cover error: prepare for auto propagated local_err
Hi all!
This is the first part of the bit series, which contains mostly simple cleanups.
v6 was sent in separate (I'm sorry for inconvenience)
v7: by Markus review (and with his prepared fixups, thanks a lot!):
- don't rename Error** paramters
- switch to Error *const * where appropriate
last patch is new and replaces
"nbd: well form nbd_iter_channel_error errp handler"
Vladimir Sementsov-Ogievskiy (21):
hw/core/loader-fit: fix freeing errp in fit_load_fdt net/net: Clean up variable shadowing in net_client_init()
error: rename errp to errp_in where it is IN-argument
hmp: drop Error pointer indirection in hmp_handle_error
vnc: drop Error pointer indirection in vnc_client_io_error
qdev-monitor: well form error hint helpers
ppc: well form kvmppc_hint_smt_possible error hint helper 9pfs: well form error hint helpers
hw/core/qdev: cleanup Error ** variables
block/snapshot: rename Error ** parameter to more common errp hw/i386/amd_iommu: rename Error ** parameter to more common errp
qga: rename Error ** parameter to more common errp monitor/qmp-cmds: rename Error ** parameter to more common errp hw/s390x: rename Error ** parameter to more common errp hw/sd: drop extra whitespace in sdhci_sysbus_realize() header hw/tpm: rename Error ** parameter to more common errp hw/usb: rename Error ** parameter to more common errp include/qom/object.h: rename Error ** parameter to more common errp backends/cryptodev: drop local_err from cryptodev_backend_complete() hw/vfio/ap: drop local_err from vfio_ap_realize
nbd: assert that Error** is not NULL in nbd_iter_channel_error
include/block/snapshot.h | 2 +- include/monitor/hmp.h | 2 +- include/qapi/error.h | 6 +- include/qom/object.h | 4 +- target/ppc/kvm_ppc.h | 4 +- ui/vnc.h | 2 +- backends/cryptodev.c | 11 +-- block/nbd.c | 1 + block/snapshot.c | 4 +- dump/dump-hmp-cmds.c | 4 +- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-proxy.c | 2 +- hw/core/loader-fit.c | 5 +- hw/core/machine-hmp-cmds.c | 6 +- hw/core/qdev.c | 28 ++++--- hw/i386/amd_iommu.c | 14 ++-- hw/ppc/spapr.c | 2 +- hw/s390x/event-facility.c | 2 +- hw/s390x/s390-stattrib.c | 3 +- hw/sd/sdhci.c | 2 +- hw/tpm/tpm_emulator.c | 8 +- hw/usb/dev-network.c | 2 +- hw/vfio/ap.c | 9 +-- monitor/hmp-cmds.c | 155 ++++++++++++++++++------------------- monitor/qmp-cmds.c | 2 +- net/net.c | 17 ++-- qdev-monitor.c | 16 ++-- qga/commands-posix.c | 2 +- qga/commands-win32.c | 2 +- qga/commands.c | 12 +-- qom/qom-hmp-cmds.c | 4 +- target/ppc/kvm.c | 2 +- ui/vnc.c | 20 ++--- util/error.c | 6 +- 34 files changed, 173 insertions(+), 190 deletions(-)
Signature · 1 line
2.21.0
PATCH v7 1/21 hw/core/loader-fit: fix freeing errp in fit_load_fdt
fit_load_fdt forget to check that errp is not NULL and to zero it after freeing. Fix it.
--- hw/core/loader-fit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/core/loader-fit.c +4 -1
@@ -200,7 +200,10 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, err =fit_image_addr (itb, img_off,"load" , &load_addr, errp);if (err == -ENOENT ) { load_addr =ROUND_UP (kernel_end,64 * KiB) + (10 * MiB); -error_free (*errp); +if (errp) { +error_free (*errp); + *errp =NULL ; + } }else if (err) {error_prepend (errp,"unable to read FDT load address from FIT: " ); ret = err;
Signature · 1 line
2.21.0
PATCH v7 2/21 net/net: Clean up variable shadowing in net_client_init()
In reply to Vladimir Sementsov-OgievskiyVariable int err in inner scope shadows Error *err in outer scope.
--- net/net.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
net/net.c +7 -10
@@ -1126,16 +1126,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) prefix_addr = substrings[0 ]; -if (substrings[1 ]) { -/* User-specified prefix length. */ -int err; - - err =qemu_strtoul (substrings[1 ],NULL ,10 , &prefix_len); -if (err) { -error_setg (errp,QERR_INVALID_PARAMETER_VALUE , -"ipv6-prefixlen" ,"a number" ); - goto out; - } +/* Handle user-specified prefix length. */ +if (substrings[1 ] && +qemu_strtoul (substrings[1 ],NULL ,10 , &prefix_len)) + { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE , +"ipv6-prefixlen" ,"a number" ); + goto out; }qemu_opt_set (opts,"ipv6-prefix" , prefix_addr, &error_abort);
Signature · 1 line
2.21.0
PATCH v7 3/21 error: rename errp to errp_in where it is IN-argument
In reply to Vladimir Sementsov-OgievskiyError **errp is almost always OUT-argument: it's assumed to be NULL, or pointer to NULL-initialized pointer, or pointer to error_abort or error_fatal, for callee to report error.
But very few functions instead get Error **errp as IN-argument:
it's assumed to be set (or, maybe, NULL), and callee should clean it, or add some information.
In such cases, rename errp to errp_in.
This patch updates only error API functions. There still a few functions with errp-in semantics, they will be updated in further commits.
--- include/qapi/error.h | 6 +++--- util/error.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
include/qapi/error.h +3 -3
@@ -233,13 +233,13 @@ void error_propagate_prepend(Error **dst_errp, Error *local_err,* Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). */ -void error_vprepend (Error **errp,const char *fmt,va_list ap); +void error_vprepend (Error *const *errp,const char *fmt,va_list ap);/* * Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, ... like printf(). */ -void error_prepend(Error **errp, const char *fmt, ...) +void error_prepend(Error *const *errp, const char *fmt, ...) GCC_FMT_ATTR(2, 3);/*
@@ -256,7 +256,7 @@ void error_prepend(Error **errp, const char *fmt, ...)* May be called multiple times. The resulting hint should end with a * newline. */ -void error_append_hint(Error **errp, const char *fmt, ...) +void error_append_hint(Error *const *errp, const char *fmt, ...) GCC_FMT_ATTR(2, 3);/*
util/error.c +3 -3
@@ -121,7 +121,7 @@ void error_setg_file_open_internal(Error **errp, "Could not open '%s'", filename); } -void error_vprepend (Error **errp,const char *fmt,va_list ap) +void error_vprepend (Error *const *errp,const char *fmt,va_list ap) {GString *newmsg;
@@ -136,7 +136,7 @@ void error_vprepend(Error **errp, const char *fmt, va_list ap) (*errp)->msg =g_string_free (newmsg,0 ); } -void error_prepend (Error **errp,const char *fmt, ...) +void error_prepend (Error *const *errp,const char *fmt, ...) {va_list ap;
@@ -145,7 +145,7 @@ void error_prepend(Error **errp, const char *fmt, ...)va_end (ap); } -void error_append_hint (Error **errp,const char *fmt, ...) +void error_append_hint (Error *const *errp,const char *fmt, ...) {va_list ap;int saved_errno = errno;
Signature · 1 line
2.21.0
Re: [PATCH v7 03/21] error: rename errp to errp_in where it is IN-argument
Quoted 10 lines · On Thu, 5 Dec 2019 18:20:01 +0300 Vladimir Sementsov-Ogievskiy…
Error **errp is almost always OUT-argument: it's assumed to be NULL, or pointer to NULL-initialized pointer, or pointer to
error_abortorerror_fatal, for callee to report error.But very few functions instead get Error **errp as IN-argument:
it's assumed to be set (or, maybe, NULL), and callee should clean it, or add some information.In such cases, rename errp to
errp_in.
This is no longer what the patch does. The subject needs to be amended too.
Quoted 70 lines
This patch updates only error API functions. There still a few functions with errp-in semantics, they will be updated in further commits.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/qapi/error.h | 6 +++--- util/error.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)include/qapi/error.h +3
-3@@ -233,13 +233,13 @@ void error_propagate_prepend(Error **dst_errp, Error *local_err,* Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). */ -void error_vprepend (Error **errp,const char *fmt,va_list ap); +void error_vprepend (Error *const *errp,const char *fmt,va_list ap);/* * Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, ... like printf(). */ -void error_prepend(Error **errp, const char *fmt, ...) +void error_prepend(Error *const *errp, const char *fmt, ...) GCC_FMT_ATTR(2, 3);/* @@ -256,7 +256,7 @@ void error_prepend(Error **errp, const char *fmt, ...)* May be called multiple times. The resulting hint should end with a * newline. */ -void error_append_hint(Error **errp, const char *fmt, ...) +void error_append_hint(Error *const *errp, const char *fmt, ...) GCC_FMT_ATTR(2, 3);/* util/error.c +3
-3@@ -121,7 +121,7 @@ void error_setg_file_open_internal(Error **errp, "Could not open '%s'", filename); } -void error_vprepend (Error **errp,const char *fmt,va_list ap) +void error_vprepend (Error *const *errp,const char *fmt,va_list ap) {GString *newmsg;@@ -136,7 +136,7 @@ void error_vprepend(Error **errp, const char *fmt, va_list ap) (*errp)->msg =g_string_free (newmsg,0 ); } -void error_prepend (Error **errp,const char *fmt, ...) +void error_prepend (Error *const *errp,const char *fmt, ...) {va_list ap;@@ -145,7 +145,7 @@ void error_prepend(Error **errp, const char *fmt, ...)va_end (ap); } -void error_append_hint (Error **errp,const char *fmt, ...) +void error_append_hint (Error *const *errp,const char *fmt, ...) {va_list ap;int saved_errno = errno;
PATCH v7 4/21 hmp: drop Error pointer indirection in hmp_handle_error
In reply to Vladimir Sementsov-OgievskiyWe don't need Error **, as all callers pass local Error object, which isn't used after the call. Use Error * instead.
--- include/monitor/hmp.h | 2 +- dump/dump-hmp-cmds.c | 4 +- hw/core/machine-hmp-cmds.c | 6 +- monitor/hmp-cmds.c | 155 ++++++++++++++++++------------------- qdev-monitor.c | 4 +- qom/qom-hmp-cmds.c | 4 +- 6 files changed, 87 insertions(+), 88 deletions(-)
include/monitor/hmp.h +1 -1
@@ -16,7 +16,7 @@#include "qemu/readline.h" -void hmp_handle_error (Monitor *mon,Error **errp); +void hmp_handle_error (Monitor *mon,Error *err);void hmp_info_name (Monitor *mon,const QDict *qdict);void hmp_info_version (Monitor *mon,const QDict *qdict);
dump/dump-hmp-cmds.c +2 -2
@@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)if (zlib + lzo + snappy + win_dmp >1 ) {error_setg (&err,"only one of '-z|-l|-s|-w' can be set" ); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err);return ; }
@@ -66,7 +66,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)qmp_dump_guest_memory (paging, prot, true, detach, has_begin, begin, has_length, length, true, dump_format, &err); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err);g_free (prot); }
hw/core/machine-hmp-cmds.c +3 -3
@@ -55,7 +55,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict) cpuid =qdict_get_int (qdict,"id" );qmp_cpu_add (cpuid, &err); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); }void hmp_hotpluggable_cpus (Monitor *mon,const QDict *qdict)
@@ -66,7 +66,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)CpuInstanceProperties *c;if (err !=NULL ) { -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err);return ; }
@@ -135,7 +135,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)monitor_printf (mon,"\n" );qapi_free_MemdevList (memdev_list); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); }void hmp_info_numa (Monitor *mon,const QDict *qdict)
monitor/hmp-cmds.c +77 -78
599 lines not on this page · raw message
qdev-monitor.c +2 -2
@@ -890,7 +890,7 @@ void hmp_device_add(Monitor *mon, const QDict *qdict)Error *err =NULL ;qmp_device_add ((QDict *)qdict,NULL , &err); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); }void hmp_device_del (Monitor *mon,const QDict *qdict)
@@ -899,7 +899,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)Error *err =NULL ;qmp_device_del (id, &err); -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); }BlockBackend *blk_by_qdev_id (const char *id,Error **errp)
qom/qom-hmp-cmds.c +2 -2
@@ -37,7 +37,7 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict) }qapi_free_ObjectPropertyInfoList (start); } -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); }void hmp_qom_set (Monitor *mon,const QDict *qdict)
@@ -59,7 +59,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict) }object_property_parse (obj, value, property, &err); } -hmp_handle_error (mon, &err); +hmp_handle_error (mon, err); } typedef struct QOMCompositionState {
Signature · 1 line
2.21.0
PATCH v7 5/21 vnc: drop Error pointer indirection in vnc_client_io_error
In reply to Vladimir Sementsov-OgievskiyWe don't need Error **, as all callers pass local Error object, which isn't used after the call, or NULL. Use Error * instead.
--- ui/vnc.h | 2 +- ui/vnc.c | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-)
ui/vnc.h +1 -1
@@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);/* Protocol stage functions */ void vnc_client_error (VncState *vs); -size_t vnc_client_io_error (VncState *vs,ssize_t ret,Error **errp); +size_t vnc_client_io_error (VncState *vs,ssize_t ret,Error *err);void start_client_init (VncState *vs);void start_auth_vnc (VncState *vs);
ui/vnc.c +7 -13
@@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs)g_free (vs); } -size_t vnc_client_io_error (VncState *vs,ssize_t ret,Error **errp) +size_t vnc_client_io_error (VncState *vs,ssize_t ret,Error *err) {if (ret <=0 ) {if (ret ==0 ) {
@@ -1320,15 +1320,11 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)vnc_disconnect_start (vs); }else if (ret !=QIO_CHANNEL_ERR_BLOCK ) {trace_vnc_client_io_error (vs, vs->ioc, - errp ?error_get_pretty (*errp) : -"Unknown" ); + err ?error_get_pretty (err) :"Unknown" );vnc_disconnect_start (vs); } -if (errp) { -error_free (*errp); - *errp =NULL ; - } +error_free (err);return 0 ; }return ret;
@@ -1361,10 +1357,9 @@ size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen) {Error *err =NULL ;ssize_t ret; - ret =qio_channel_write ( - vs->ioc, (const char *)data, datalen, &err); + ret =qio_channel_write (vs->ioc, (const char *)data, datalen, &err);VNC_DEBUG ("Wrote wire %p %zd -> %ld\n" , data, datalen, ret); -return vnc_client_io_error (vs, ret, &err); +return vnc_client_io_error (vs, ret, err); }
@@ -1488,10 +1483,9 @@ size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen) {ssize_t ret;Error *err =NULL ; - ret =qio_channel_read ( - vs->ioc, (char *)data, datalen, &err); + ret =qio_channel_read (vs->ioc, (char *)data, datalen, &err);VNC_DEBUG ("Read wire %p %zd -> %ld\n" , data, datalen, ret); -return vnc_client_io_error (vs, ret, &err); +return vnc_client_io_error (vs, ret, err); }
Signature · 1 line
2.21.0
PATCH v7 6/21 qdev-monitor: well form error hint helpers
In reply to Vladimir Sementsov-OgievskiyMake qbus_list_bus and qbus_list_dev hint append helpers well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual for errp), rename functions to be error_append_*_hint.
--- qdev-monitor.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
qdev-monitor.c +7 -5
@@ -328,7 +328,8 @@ static Object *qdev_get_peripheral_anon(void)return dev; } -static void qbus_list_bus (DeviceState *dev,Error **errp) +static void qbus_error_append_bus_list_hint (DeviceState *dev, +Error *const *errp) {BusState *child;const char *sep =" " ;
@@ -342,7 +343,8 @@ static void qbus_list_bus(DeviceState *dev, Error **errp)error_append_hint (errp,"\n" ); } -static void qbus_list_dev (BusState *bus,Error **errp) +static void qbus_error_append_dev_list_hint (BusState *bus, +Error *const *errp) {BusChild *kid;const char *sep =" " ;
@@ -500,7 +502,7 @@ static BusState *qbus_find(const char *path, Error **errp)if (!dev) {error_set (errp,ERROR_CLASS_DEVICE_NOT_FOUND ,"Device '%s' not found" , elem); -qbus_list_dev (bus, errp); +qbus_error_append_dev_list_hint (bus, errp);return NULL ; }
@@ -518,7 +520,7 @@ static BusState *qbus_find(const char *path, Error **errp)if (dev->num_child_bus) {error_setg (errp,"Device '%s' has multiple child buses" , elem); -qbus_list_bus (dev, errp); +qbus_error_append_bus_list_hint (dev, errp); }else {error_setg (errp,"Device '%s' has no child bus" , elem); }
@@ -534,7 +536,7 @@ static BusState *qbus_find(const char *path, Error **errp) bus =qbus_find_bus (dev, elem);if (!bus) {error_setg (errp,"Bus '%s' not found" , elem); -qbus_list_bus (dev, errp); +qbus_error_append_bus_list_hint (dev, errp);return NULL ; } }
Signature · 1 line
2.21.0
Re: [PATCH v7 06/21] qdev-monitor: well form error hint helpers
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Make
qbus_list_busandqbus_list_devhint append helpers well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp), rename functions to be error_append_*_hint.
Commit message mentions a rename...
Quoted 11 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- qdev-monitor.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)qdev-monitor.c +0
-0
qdev-monitor.c static Object *qdev_get_peripheral_anon(void) · line 332
Quoted 6 lines
qdev-monitor.c +2
-1@@ -328,7 +328,8 @@ static Object *qdev_get_peripheral_anon(void)return dev; } -static void qbus_list_bus (DeviceState *dev,Error **errp) +static void qbus_error_append_bus_list_hint (DeviceState *dev, +Error *const *errp)
...but instead you did a type change with the name left unchanged. Commit message needs a fix.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v7 06/21] qdev-monitor: well form error hint helpers
Quoted 13 lines · Eric Blake
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Make
qbus_list_busandqbus_list_devhint append helpers well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp), rename functions to be error_append_*_hint.Commit message mentions a rename...
Quoted 6 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
qdev-monitor.c| 12 +++++++-----1 file changed, 7 insertions(+), 5 deletions(-)
Quoted 13 lines
qdev-monitor.c static Object *qdev_get_peripheral_anon(void) · line 331
Quoted 10 lines
qdev-monitor.c +2
-1@@ -328,7 +328,8 @@ static Object *qdev_get_peripheral_anon(void) return dev; } -static void qbus_list_bus (DeviceState *dev,Error **errp) +static void qbus_error_append_bus_list_hint (DeviceState *dev, + Error *const *errp)...but instead you did a type change with the name left unchanged. Commit message needs a fix.
Oops. I blindly take Markus's fixum, and didn't fix commit messages. I'll resend.
Signature · 2 lines
Best regards, Vladimir
PATCH v7 7/21 ppc: well form kvmppc_hint_smt_possible error hint helper
In reply to Vladimir Sementsov-OgievskiyMake kvmppc_hint_smt_possible hint append helper well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual for errp), rename function to be kvmppc_error_append_*_hint.
--- target/ppc/kvm_ppc.h | 4 ++-- hw/ppc/spapr.c | 2 +- target/ppc/kvm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
target/ppc/kvm_ppc.h +2 -2
@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);int kvmppc_set_compat (PowerPCCPU *cpu,uint32_t compat_pvr);void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);int kvmppc_smt_threads (void ); -void kvmppc_hint_smt_possible (Error **errp); +void kvmppc_error_append_smt_possible_hint (Error *const *errp);int kvmppc_set_smt_threads (int smt);int kvmppc_clear_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);int kvmppc_or_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);
@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)return 1 ; } -static inline void kvmppc_hint_smt_possible (Error **errp) +static inline void kvmppc_error_append_smt_possible_hint (Error *const *errp) {return ; }
hw/ppc/spapr.c +1 -1
@@ -2564,7 +2564,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)" requires the use of VSMT mode %d.\n" , smp_threads, kvm_smt, spapr->vsmt); } -kvmppc_hint_smt_possible (&local_err); +kvmppc_error_append_smt_possible_hint (&local_err); goto out; } }
target/ppc/kvm.c +1 -1
@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)return ret; } -void kvmppc_hint_smt_possible (Error **errp) +void kvmppc_error_append_smt_possible_hint (Error *const *errp) {int i;GString *g;
Signature · 1 line
2.21.0
Re: [PATCH v7 07/21] ppc: well form kvmppc_hint_smt_possible error hint helper
Quoted 6 lines · On Thu, 5 Dec 2019 18:20:05 +0300 Vladimir Sementsov-Ogievskiy…
Make
kvmppc_hint_smt_possiblehint append helper well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp), rename function to be kvmppc_error_append_*_hint.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
The changelog needs to be amended. Apart from that:
Quoted 53 lines
target/ppc/kvm_ppc.h | 4 ++-- hw/ppc/spapr.c | 2 +- target/ppc/kvm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)target/ppc/kvm_ppc.h +2
-2@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);int kvmppc_set_compat (PowerPCCPU *cpu,uint32_t compat_pvr);void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);int kvmppc_smt_threads (void ); -void kvmppc_hint_smt_possible (Error **errp); +void kvmppc_error_append_smt_possible_hint (Error *const *errp);int kvmppc_set_smt_threads (int smt);int kvmppc_clear_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);int kvmppc_or_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)return 1 ; } -static inline void kvmppc_hint_smt_possible (Error **errp) +static inline void kvmppc_error_append_smt_possible_hint (Error *const *errp) {return ; }hw/ppc/spapr.c +1
-1@@ -2564,7 +2564,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)" requires the use of VSMT mode %d.\n" , smp_threads, kvm_smt, spapr->vsmt); } -kvmppc_hint_smt_possible (&local_err); +kvmppc_error_append_smt_possible_hint (&local_err); goto out; } }target/ppc/kvm.c +1
-1@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)return ret; } -void kvmppc_hint_smt_possible (Error **errp) +void kvmppc_error_append_smt_possible_hint (Error *const *errp) {int i;GString *g;
Re: [PATCH v7 07/21] ppc: well form kvmppc_hint_smt_possible error hint helper
In reply to Vladimir Sementsov-OgievskiyQuoted 6 lines · Vladimir Sementsov-Ogievskiy
Make
kvmppc_hint_smt_possiblehint append helper well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp), rename function to be kvmppc_error_append_*_hint.Signed-off-by: Vladimir Sementsov-Ogievskiy
<[email protected]>
Apart from Greg's point about the changelog,
Quoted 54 lines
--- target/ppc/kvm_ppc.h | 4 ++-- hw/ppc/spapr.c | 2 +- target/ppc/kvm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)target/ppc/kvm_ppc.h +2
-2@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);int kvmppc_set_compat (PowerPCCPU *cpu,uint32_t compat_pvr);void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);int kvmppc_smt_threads (void ); -void kvmppc_hint_smt_possible (Error **errp); +void kvmppc_error_append_smt_possible_hint (Error *const *errp);int kvmppc_set_smt_threads (int smt);int kvmppc_clear_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);int kvmppc_or_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)return 1 ; } -static inline void kvmppc_hint_smt_possible (Error **errp) +static inline void kvmppc_error_append_smt_possible_hint (Error *const *errp) {return ; }hw/ppc/spapr.c +1
-1@@ -2564,7 +2564,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)" requires the use of VSMT mode %d.\n" , smp_threads, kvm_smt, spapr->vsmt); } -kvmppc_hint_smt_possible (&local_err); +kvmppc_error_append_smt_possible_hint (&local_err); goto out; } }target/ppc/kvm.c +1
-1@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)return ret; } -void kvmppc_hint_smt_possible (Error **errp) +void kvmppc_error_append_smt_possible_hint (Error *const *errp) {int i;GString *g;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH v7 07/21] ppc: well form kvmppc_hint_smt_possible error hint helper
Quoted 11 lines · David Gibson
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Make
kvmppc_hint_smt_possiblehint append helper well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp), rename function to be kvmppc_error_append_*_hint.Signed-off-by: Vladimir Sementsov-Ogievskiy
<[email protected]>Apart from Greg's point about the changelog,
Acked-by David Gibson <[email protected]>
Thanks! actually, v8 is out with fixed commit message
Quoted 56 lines
Quoted 55 lines
--- target/ppc/kvm_ppc.h | 4 ++-- hw/ppc/spapr.c | 2 +- target/ppc/kvm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)target/ppc/kvm_ppc.h +2
-2@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);int kvmppc_set_compat (PowerPCCPU *cpu,uint32_t compat_pvr);void kvmppc_set_mpic_proxy (PowerPCCPU *cpu,int mpic_proxy);int kvmppc_smt_threads (void ); -void kvmppc_hint_smt_possible (Error **errp); +void kvmppc_error_append_smt_possible_hint (Error *const *errp);int kvmppc_set_smt_threads (int smt);int kvmppc_clear_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);int kvmppc_or_tsr_bits (PowerPCCPU *cpu,uint32_t tsr_bits);@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)return 1 ; } -static inline void kvmppc_hint_smt_possible (Error **errp) +static inline void kvmppc_error_append_smt_possible_hint (Error *const *errp) {return ; }hw/ppc/spapr.c +1
-1@@ -2564,7 +2564,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)" requires the use of VSMT mode %d.\n" , smp_threads, kvm_smt, spapr->vsmt); } -kvmppc_hint_smt_possible (&local_err); +kvmppc_error_append_smt_possible_hint (&local_err); goto out; } }target/ppc/kvm.c +1
-1@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)return ret; } -void kvmppc_hint_smt_possible (Error **errp) +void kvmppc_error_append_smt_possible_hint (Error *const *errp) {int i;GString *g;
Signature · 2 lines
Best regards, Vladimir
PATCH v7 8/21 9pfs: well form error hint helpers
In reply to Vladimir Sementsov-OgievskiyMake error_append_security_model_hint and error_append_socket_sockfd_hint hint append helpers well formed:
rename errp to errp_in, as it is IN-parameter here (which is unusual for errp).
--- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-proxy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/9pfs/9p-local.c +1 -1
@@ -1473,7 +1473,7 @@ static void local_cleanup(FsContext *ctx)g_free (data); } -static void error_append_security_model_hint (Error **errp) +static void error_append_security_model_hint (Error *const *errp) {error_append_hint (errp,"Valid options are: security_model=" "[passthrough|mapped-xattr|mapped-file|none]\n" );
hw/9pfs/9p-proxy.c +1 -1
@@ -1114,7 +1114,7 @@ static int connect_namedsocket(const char *path, Error **errp)return sockfd; } -static void error_append_socket_sockfd_hint (Error **errp) +static void error_append_socket_sockfd_hint (Error *const *errp) {error_append_hint (errp,"Either specify socket=/some/path where /some/path" " points to a listening AF_UNIX socket or sock_fd=fd"
Signature · 1 line
2.21.0
Re: [PATCH v7 08/21] 9pfs: well form error hint helpers
Quoted 7 lines · On Thu, 5 Dec 2019 18:20:06 +0300 Vladimir Sementsov-Ogievskiy…
Make
error_append_security_model_hintanderror_append_socket_sockfd_hinthint append helpers well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp).Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Quoted 30 lines
hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-proxy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/9pfs/9p-local.c +1
-1@@ -1473,7 +1473,7 @@ static void local_cleanup(FsContext *ctx)g_free (data); } -static void error_append_security_model_hint (Error **errp) +static void error_append_security_model_hint (Error *const *errp) {error_append_hint (errp,"Valid options are: security_model=" "[passthrough|mapped-xattr|mapped-file|none]\n" );hw/9pfs/9p-proxy.c +1
-1@@ -1114,7 +1114,7 @@ static int connect_namedsocket(const char *path, Error **errp)return sockfd; } -static void error_append_socket_sockfd_hint (Error **errp) +static void error_append_socket_sockfd_hint (Error *const *errp) {error_append_hint (errp,"Either specify socket=/some/path where /some/path" " points to a listening AF_UNIX socket or sock_fd=fd"
Re: [PATCH v7 08/21] 9pfs: well form error hint helpers
Quoted 8 lines · On Thu, 5 Dec 2019 18:08:56 +0100 Greg Kurz <[email protected]> wrote:
Quoted 5 lines · On Thu, 5 Dec 2019 18:20:06 +0300 Vladimir Sementsov-Ogievskiy…
Make
error_append_security_model_hintanderror_append_socket_sockfd_hinthint append helpers well formed:
rename errp toerrp_in, as it is IN-parameter here (which is unusual for errp).
Quoted 5 lines
Quoted 2 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Acked-by Greg Kurz <[email protected]>
With an updated changelog that no longer mentions errp_in :)
Quoted 31 lines
Quoted 30 lines
hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-proxy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/9pfs/9p-local.c +1
-1@@ -1473,7 +1473,7 @@ static void local_cleanup(FsContext *ctx)g_free (data); } -static void error_append_security_model_hint (Error **errp) +static void error_append_security_model_hint (Error *const *errp) {error_append_hint (errp,"Valid options are: security_model=" "[passthrough|mapped-xattr|mapped-file|none]\n" );hw/9pfs/9p-proxy.c +1
-1@@ -1114,7 +1114,7 @@ static int connect_namedsocket(const char *path, Error **errp)return sockfd; } -static void error_append_socket_sockfd_hint (Error **errp) +static void error_append_socket_sockfd_hint (Error *const *errp) {error_append_hint (errp,"Either specify socket=/some/path where /some/path" " points to a listening AF_UNIX socket or sock_fd=fd"
PATCH v7 9/21 hw/core/qdev: cleanup Error ** variables
In reply to Vladimir Sementsov-OgievskiyRename Error ** parameter in check_only_migratable to common errp.
In device_set_realized:
- Move "if (local_err != NULL)" closer to error setters.
- Drop 'Error **local_errp': it doesn't save any LoCs, but it's very unusual.
--- hw/core/qdev.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
hw/core/qdev.c +13 -15
@@ -820,12 +820,12 @@ static bool device_get_realized(Object *obj, Error **errp)return dev->realized; } -static bool check_only_migratable (Object *obj,Error **err) +static bool check_only_migratable (Object *obj,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (obj);if (!vmstate_check_only_migratable (dc->vmsd)) { -error_setg (err,"Device %s is not migratable, but " +error_setg (errp,"Device %s is not migratable, but " "--only-migratable was specified" ,object_get_typename (obj));return false;
@@ -874,10 +874,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)if (dc->realize) { dc->realize (dev, &local_err); - } - -if (local_err !=NULL ) { - goto fail; +if (local_err !=NULL ) { + goto fail; + } }DEVICE_LISTENER_CALL (realize, Forward, dev);
@@ -918,27 +917,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp) } }else if (!value && dev->realized) { -Error **local_errp =NULL ; +/* We want local_err to track only the first error */ QLIST_FOREACH(bus, &dev->child_bus, sibling) { - local_errp = local_err ?NULL : &local_err;object_property_set_bool (OBJECT (bus), false,"realized" , - local_errp); + local_err ?NULL : &local_err); }if (qdev_get_vmsd (dev)) {vmstate_unregister (dev,qdev_get_vmsd (dev), dev); }if (dc->unrealize) { - local_errp = local_err ?NULL : &local_err; - dc->unrealize (dev, local_errp); + dc->unrealize (dev, local_err ?NULL : &local_err); } dev->pending_deleted_event = true;DEVICE_LISTENER_CALL (unrealize, Reverse, dev); - } -if (local_err !=NULL ) { - goto fail; +if (local_err !=NULL ) { + goto fail; + } } +assert (local_err ==NULL ); dev->realized = value;return ;
@@ -976,7 +974,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp) qbus_is_hotpluggable(dev->parent_bus)); } -static bool device_get_hotplugged (Object *obj,Error **err) +static bool device_get_hotplugged (Object *obj,Error **errp) {DeviceState *dev =DEVICE (obj);
Signature · 1 line
2.21.0
PATCH v7 10/21 block/snapshot: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- include/block/snapshot.h | 2 +- block/snapshot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/block/snapshot.h +1 -1
@@ -78,7 +78,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,bool bdrv_all_can_snapshot (BlockDriverState **first_bad_bs);int bdrv_all_delete_snapshot (const char *name,BlockDriverState **first_bsd_bs, -Error **err); +Error **errp);int bdrv_all_goto_snapshot (const char *name,BlockDriverState **first_bad_bs,Error **errp);int bdrv_all_find_snapshot (const char *name,BlockDriverState **first_bad_bs);
block/snapshot.c +2 -2
@@ -426,7 +426,7 @@ fail: }int bdrv_all_delete_snapshot (const char *name,BlockDriverState **first_bad_bs, -Error **err) +Error **errp) {int ret =0 ;BlockDriverState *bs;
@@ -441,7 +441,7 @@ int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs, bdrv_snapshot_find(bs, snapshot, name) >= 0) { ret =bdrv_snapshot_delete (bs, snapshot->id_str, - snapshot->name, err); + snapshot->name, errp); }aio_context_release (ctx);if (ret <0 ) {
Signature · 1 line
2.21.0
PATCH v7 11/21 hw/i386/amd_iommu: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- hw/i386/amd_iommu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/i386/amd_iommu.c +7 -7
@@ -1533,7 +1533,7 @@ static void amdvi_reset(DeviceState *dev)amdvi_init (s); } -static void amdvi_realize (DeviceState *dev,Error **err) +static void amdvi_realize (DeviceState *dev,Error **errp) {int ret =0 ;AMDVIState *s =AMD_IOMMU_DEVICE (dev);
@@ -1549,21 +1549,21 @@ static void amdvi_realize(DeviceState *dev, Error **err)/* This device should take care of IOMMU PCI properties */ x86_iommu->type =TYPE_AMD ;qdev_set_parent_bus (DEVICE (&s->pci), &bus->qbus); -object_property_set_bool (OBJECT (&s->pci), true,"realized" , err); +object_property_set_bool (OBJECT (&s->pci), true,"realized" , errp); ret =pci_add_capability (&s->pci.dev,AMDVI_CAPAB_ID_SEC ,0 , -AMDVI_CAPAB_SIZE , err); +AMDVI_CAPAB_SIZE , errp);if (ret <0 ) {return ; } s->capab_offset = ret; ret =pci_add_capability (&s->pci.dev,PCI_CAP_ID_MSI ,0 , -AMDVI_CAPAB_REG_SIZE , err); +AMDVI_CAPAB_REG_SIZE , errp);if (ret <0 ) {return ; } ret =pci_add_capability (&s->pci.dev,PCI_CAP_ID_HT ,0 , -AMDVI_CAPAB_REG_SIZE , err); +AMDVI_CAPAB_REG_SIZE , errp);if (ret <0 ) {return ; }
@@ -1578,8 +1578,8 @@ static void amdvi_realize(DeviceState *dev, Error **err)sysbus_init_mmio (SYS_BUS_DEVICE (s), &s->mmio);sysbus_mmio_map (SYS_BUS_DEVICE (s),0 ,AMDVI_BASE_ADDR );pci_setup_iommu (bus, amdvi_host_dma_iommu, s); - s->devid =object_property_get_int (OBJECT (&s->pci),"addr" , err); -msi_init (&s->pci.dev,0 ,1 , true, false, err); + s->devid =object_property_get_int (OBJECT (&s->pci),"addr" , errp); +msi_init (&s->pci.dev,0 ,1 , true, false, errp);amdvi_init (s); }
Signature · 1 line
2.21.0
PATCH v7 12/21 qga: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- qga/commands-posix.c | 2 +- qga/commands-win32.c | 2 +- qga/commands.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-)
qga/commands-posix.c +1 -1
@@ -2781,7 +2781,7 @@ static double ga_get_login_time(struct utmpx *user_info)return seconds + useconds; } -GuestUserList *qmp_guest_get_users (Error **err) +GuestUserList *qmp_guest_get_users (Error **errp) {GHashTable *cache =NULL ;GuestUserList *head =NULL , *cur_item =NULL ;
qga/commands-win32.c +1 -1
@@ -1946,7 +1946,7 @@ typedef struct _GA_WTSINFOA { }GA_WTSINFOA ; -GuestUserList *qmp_guest_get_users (Error **err) +GuestUserList *qmp_guest_get_users (Error **errp) {#define QGA_NANOSECONDS 10000000
qga/commands.c +6 -6
@@ -143,7 +143,7 @@ static GuestExecInfo *guest_exec_info_find(int64_t pid_numeric)return NULL ; } -GuestExecStatus *qmp_guest_exec_status (int64_t pid,Error **err) +GuestExecStatus *qmp_guest_exec_status (int64_t pid,Error **errp) {GuestExecInfo *gei;GuestExecStatus *ges;
@@ -152,7 +152,7 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err) gei =guest_exec_info_find (pid);if (gei ==NULL ) { -error_setg (err,QERR_INVALID_PARAMETER ,"pid" ); +error_setg (errp,QERR_INVALID_PARAMETER ,"pid" );return NULL ; }
@@ -385,7 +385,7 @@ GuestExec *qmp_guest_exec(const char *path, bool has_env, strList *env, bool has_input_data, const char *input_data, bool has_capture_output, bool capture_output, - Error **err) + Error **errp) { GPid pid;GuestExec *ge =NULL ;
@@ -405,7 +405,7 @@ GuestExec *qmp_guest_exec(const char *path, arglist.next = has_arg ? arg :NULL ;if (has_input_data) { - input =qbase64_decode (input_data,-1 , &ninput, err); + input =qbase64_decode (input_data,-1 , &ninput, errp);if (!input) {return NULL ; }
@@ -424,7 +424,7 @@ GuestExec *qmp_guest_exec(const char *path, guest_exec_task_setup,NULL , &pid, has_input_data ? &in_fd :NULL , has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr);if (!ret) { -error_setg (err,QERR_QGA_COMMAND_FAILED , gerr->message); +error_setg (errp,QERR_QGA_COMMAND_FAILED , gerr->message);g_error_free (gerr); goto done; }
@@ -499,7 +499,7 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)return -1 ; } -GuestHostName *qmp_guest_get_host_name (Error **err) +GuestHostName *qmp_guest_get_host_name (Error **errp) {GuestHostName *result =NULL ;gchar const *hostname =g_get_host_name ();
Signature · 1 line
2.21.0
PATCH v7 13/21 monitor/qmp-cmds: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- monitor/qmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/qmp-cmds.c +1 -1
@@ -109,7 +109,7 @@ void qmp_system_reset(Error **errp)qemu_system_reset_request (SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET ); } -void qmp_system_powerdown (Error **erp) +void qmp_system_powerdown (Error **errp) {qemu_system_powerdown_request (); }
Signature · 1 line
2.21.0
PATCH v7 14/21 hw/s390x: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- hw/s390x/event-facility.c | 2 +- hw/s390x/s390-stattrib.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/s390x/event-facility.c +1 -1
@@ -439,7 +439,7 @@ static void sclp_event_set_allow_all_mask_sizes(Object *obj, bool value, ef->allow_all_mask_sizes = value; } -static bool sclp_event_get_allow_all_mask_sizes (Object *obj,Error **e) +static bool sclp_event_get_allow_all_mask_sizes (Object *obj,Error **errp) {SCLPEventFacility *ef = (SCLPEventFacility *)obj;
hw/s390x/s390-stattrib.c +2 -1
@@ -352,7 +352,8 @@ static void s390_stattrib_class_init(ObjectClass *oc, void *data) dc->realize = s390_stattrib_realize; } -static inline bool s390_stattrib_get_migration_enabled (Object *obj,Error **e) +static inline bool s390_stattrib_get_migration_enabled (Object *obj, +Error **errp) {S390StAttribState *s =S390_STATTRIB (obj);
Signature · 1 line
2.21.0
PATCH v7 15/21 hw/sd: drop extra whitespace in sdhci_sysbus_realize() header
In reply to Vladimir Sementsov-Ogievskiy--- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
@@ -1459,7 +1459,7 @@ static void sdhci_sysbus_finalize(Object *obj)sdhci_uninitfn (s); } -static void sdhci_sysbus_realize (DeviceState *dev,Error ** errp) +static void sdhci_sysbus_realize (DeviceState *dev,Error **errp) {SDHCIState *s =SYSBUS_SDHCI (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
Signature · 1 line
2.21.0
PATCH v7 16/21 hw/tpm: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- hw/tpm/tpm_emulator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/tpm/tpm_emulator.c +4 -4
@@ -155,7 +155,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu, const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t out_len, bool *selftest_done, - Error **err) + Error **errp) { ssize_t ret;bool is_selftest = false;
@@ -165,20 +165,20 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu, is_selftest =tpm_util_is_selftest (in, in_len); } - ret =qio_channel_write_all (tpm_emu->data_ioc, (char *)in, in_len, err); + ret =qio_channel_write_all (tpm_emu->data_ioc, (char *)in, in_len, errp);if (ret !=0 ) {return -1 ; } ret =qio_channel_read_all (tpm_emu->data_ioc, (char *)out, -sizeof (struct tpm_resp_hdr ), err); +sizeof (struct tpm_resp_hdr ), errp);if (ret !=0 ) {return -1 ; } ret =qio_channel_read_all (tpm_emu->data_ioc, (char *)out +sizeof (struct tpm_resp_hdr ), -tpm_cmd_get_size (out) -sizeof (struct tpm_resp_hdr ), err); +tpm_cmd_get_size (out) -sizeof (struct tpm_resp_hdr ), errp);if (ret !=0 ) {return -1 ; }
Signature · 1 line
2.21.0
PATCH v7 17/21 hw/usb: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- hw/usb/dev-network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/dev-network.c +1 -1
@@ -1342,7 +1342,7 @@ static NetClientInfo net_usbnet_info = { .cleanup = usbnet_cleanup, }; -static void usb_net_realize (USBDevice *dev,Error **errrp) +static void usb_net_realize (USBDevice *dev,Error **errp) {USBNetState *s =USB_NET (dev);
Signature · 1 line
2.21.0
PATCH v7 18/21 include/qom/object.h: rename Error ** parameter to more common errp
In reply to Vladimir Sementsov-Ogievskiy--- include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/qom/object.h +2 -2
@@ -1635,9 +1635,9 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,* property of type 'uint64'. */ void object_property_add_uint64_ptr (Object *obj,const char *name, -const uint64_t *v,Error **Errp); +const uint64_t *v,Error **errp);void object_class_property_add_uint64_ptr (ObjectClass *klass,const char *name, -const uint64_t *v,Error **Errp); +const uint64_t *v,Error **errp);/** * object_property_add_alias:
Signature · 1 line
2.21.0
PATCH v7 19/21 backends/cryptodev: drop local_err from cryptodev_backend_complete()
In reply to Vladimir Sementsov-OgievskiyNo reason for local_err here, use errp directly instead.
--- backends/cryptodev.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
backends/cryptodev.c +1 -10
@@ -176,19 +176,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp) {CryptoDevBackend *backend =CRYPTODEV_BACKEND (uc);CryptoDevBackendClass *bc =CRYPTODEV_BACKEND_GET_CLASS (uc); -Error *local_err =NULL ;if (bc->init) { - bc->init (backend, &local_err); -if (local_err) { - goto out; - } + bc->init (backend, errp); } - -return ; - -out: -error_propagate (errp, local_err); }void cryptodev_backend_set_used (CryptoDevBackend *backend,bool used)
Signature · 1 line
2.21.0
PATCH v7 20/21 hw/vfio/ap: drop local_err from vfio_ap_realize
In reply to Vladimir Sementsov-OgievskiyNo reason for local_err here, use errp directly instead.
--- hw/vfio/ap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/vfio/ap.c +3 -6
@@ -89,14 +89,13 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) {int ret;char *mdevid; -Error *local_err =NULL ;VFIOGroup *vfio_group;APDevice *apdev =AP_DEVICE (dev);VFIOAPDevice *vapdev =VFIO_AP_DEVICE (apdev); - vfio_group =vfio_ap_get_group (vapdev, &local_err); + vfio_group =vfio_ap_get_group (vapdev, errp);if (!vfio_group) { - goto out_err; +return ; } vapdev->vdev.ops = &vfio_ap_ops;
@@ -113,7 +112,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)*/ vapdev->vdev.balloon_allowed = true; - ret =vfio_get_device (vfio_group, mdevid, &vapdev->vdev, &local_err); + ret =vfio_get_device (vfio_group, mdevid, &vapdev->vdev, errp);if (ret) { goto out_get_dev_err; }
@@ -123,8 +122,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) out_get_dev_err:vfio_ap_put_device (vapdev);vfio_put_group (vfio_group); -out_err: -error_propagate (errp, local_err); }static void vfio_ap_unrealize (DeviceState *dev,Error **errp)
Signature · 1 line
2.21.0
Re: [PATCH v7 20/21] hw/vfio/ap: drop local_err from vfio_ap_realize
Quoted 7 lines · On Thu, 5 Dec 2019 18:20:18 +0300 Vladimir Sementsov-Ogievskiy…
No reason for
local_errhere, use errp directly instead.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Reviewed-by Markus Armbruster <[email protected]>--- hw/vfio/ap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
PATCH v7 21/21 nbd: assert that Error** is not NULL in nbd_iter_channel_error
In reply to Vladimir Sementsov-OgievskiyThe local_err parameter is not here to return information about nbd_iter_channel_error failure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.
--- block/nbd.c | 1 + 1 file changed, 1 insertion(+)
block/nbd.c +1 -0
@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter {static void nbd_iter_channel_error (NBDReplyChunkIter *iter,int ret,Error **local_err) { +assert (local_err && *local_err);assert (ret <0 );if (!iter->ret) {
Signature · 1 line
2.21.0
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/nbd.c | 1 + 1 file changed, 1 insertion(+)block/nbd.c +0
-0
block/nbd.c typedef struct NBDReplyChunkIter { · line 869
Quoted 4 lines
block/nbd.c +1
-0@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter {static void nbd_iter_channel_error (NBDReplyChunkIter *iter,int ret,Error **local_err) { +assert (local_err && *local_err);
Why are we forbidding grandparent callers from passing NULL when they want to ignore an error? We are called by several parent functions that get an errp from the grandparent, and use this function to do some common grunt work. Let's look at the possibilities:
1. grandparent passes address of a local error: we want to append to the error message, parent will then deal with the error how it wants (report it, ignore it, propagate it, whatever)
2. grandparent passes &error_fatal: we want to append a hint, but before ERRP_AUTO_PROPAGATE, the parent has already exited. After ERRP_AUTO_PROPAGATE, this looks like case 1.
3. grandparent passes &error_abort: we should never be reached (failure earlier in the parent should have already aborted) - true whether or not ERRP_AUTO_PROPAGATE is applied
4. grandparent passes NULL to ignore the error. Does not currently happen in any of the grandparent callers, because if it did, your assertion in this patch would now fire. After ERRP_AUTO_PROPAGATE, this would look like case 1.
Would it be better to assert(!local_err || *local_err)? The assertion as written is too strict without ERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.
Quoted 4 lines
block/nbd.c +0
-0assert (ret <0 );if (!iter->ret) {
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 26 lines · Eric Blake
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
block/nbd.c| 1 +1 file changed, 1 insertion(+)block/nbd.c +0
-0block/nbd.c typedef struct NBDReplyChunkIter { · line 869
Quoted 4 lines
block/nbd.c +1
-0@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter { static void nbd_iter_channel_error(NBDReplyChunkIter *iter, int ret, Error **local_err) { + assert(local_err && *local_err);Why are we forbidding grandparent callers from passing NULL when they want to ignore an error? We are called by several parent functions that get an errp from the grandparent, and use this function to do some common grunt work. Let's look at the possibilities:
1. grandparent passes address of a local error: we want to append to the error message, parent will then deal with the error how it wants (report it, ignore it, propagate it, whatever)
Quoted 7 lines
2. grandparent passes
&error_fatal: we want to append a hint, but beforeERRP_AUTO_PROPAGATE, the parent has already exited. AfterERRP_AUTO_PROPAGATE, this looks like case 1.3. grandparent passes
&error_abort: we should never be reached (failure earlier in the parent should have already aborted) - true whether or notERRP_AUTO_PROPAGATEis applied4. grandparent passes NULL to ignore the error. Does not currently happen in any of the grandparent callers, because if it did, your assertion in this patch would now fire. After
ERRP_AUTO_PROPAGATE, this would look like case 1.Would it be better to
assert(!local_err || *local_err)? The assertion as written is too strict withoutERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.
We don't have any grandparents, this function is always called on local_err. And it's argument named local_err to stress it. The function is an API to report error, and it wants filled local_err object.
It will crash anyway if local_err is NULL, as it dereferences it.
I just want to place an assertion at start of functions like this, which will be easily recognizable by coccinelle.
---
We can improve the API, to support local_err==NULL, for the case when original request was called with errp==NULL, but for this we'll need more changes, like, pass errp to NBD_FOREACH_REPLY_CHUNK and save it into iter object...
But how to detect it in code? Something like
block/nbd.c +4 -2
@@ -1059,8 +1059,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,case NBD_REPLY_TYPE_BLOCK_STATUS :if (received) {nbd_channel_error (s, -EINVAL ); -error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); -nbd_iter_channel_error (&iter, -EINVAL , &local_err); +if (errp) { +error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); + } +nbd_iter_channel_error (&iter, -EINVAL , errp ? &local_err :NULL ); } received = true;
is ugly..
So, to support original errp=NULL the whole thing should be refactored.. Not worth it, I think.
Quoted 5 lines
Quoted 4 lines
block/nbd.c +0
-0assert(ret < 0); if (!iter->ret) {
Signature · 2 lines
Best regards, Vladimir
Eric Blake
Reviewed-byRe: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 10 lines · Vladimir Sementsov-Ogievskiy
Quoted 9 lines · Eric Blake
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.
Quoted 3 lines
Quoted 1 line
Would it be better to
assert(!local_err || *local_err)? The assertion as written is too strict withoutERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.We don't have any grandparents, this function is always called on
local_err. And it's argument namedlocal_errto stress it.
Then the commit message should state that. How about:
All callers of nbd_iter_channel_error() pass the address of a local_err variable, and only call this function if an error has already occurred, using this function to append details to that error. This is already implied by its name (local_err instead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.
Quoted 6 lines
The function is an API to report error, and it wants filled
local_errobject.It will crash anyway if
local_erris NULL, as it dereferences it.I just want to place an assertion at start of functions like this, which will be easily recognizable by coccinelle.
With an improved commit message, the assertion makes sense, so
Quoted 13 lines
---
We can improve the API, to support local_err==NULL, for the case when original request was called with errp==NULL, but for this we'll need more changes, like, pass errp to
NBD_FOREACH_REPLY_CHUNKand save it into iter object...But how to detect it in code? Something like
block/nbd.c static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s, · line 1065
Quoted 9 lines
block/nbd.c +4
-2@@ -1059,8 +1059,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,case NBD_REPLY_TYPE_BLOCK_STATUS :if (received) {nbd_channel_error (s, -EINVAL ); -error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); -nbd_iter_channel_error (&iter, -EINVAL , &local_err); +if (errp) { +error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); + } +nbd_iter_channel_error (&iter, -EINVAL , errp ? &local_err :NULL );
No, that's not worth it.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 13 lines · Eric Blake
Quoted 12 lines · Vladimir Sementsov-Ogievskiy
Quoted 10 lines · Eric Blake
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.Would it be better to
assert(!local_err || *local_err)? The assertion as written is too strict withoutERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.
Quoted 7 lines
Quoted 1 line
We don't have any grandparents, this function is always called on
local_err. And it's argument namedlocal_errto stress it.Then the commit message should state that. How about:
All callers of
nbd_iter_channel_error()pass the address of alocal_errvariable, and only call this function if an error has already occurred, using this functionto append details to that error.
Hmm, not to append details but to report the error to the magical receiving loop, which doesn't yet know about the error
Quoted 1 line
This is already implied by its name (
local_errinstead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.
So, how about simply s/to append details to that error/to report that error/ ?
Quoted 37 lines
Quoted 7 lines
The function is an API to report error, and it wants filled
local_errobject.It will crash anyway if
local_erris NULL, as it dereferences it.I just want to place an assertion at start of functions like this, which will be easily recognizable by coccinelle.
With an improved commit message, the assertion makes sense, so
Reviewed-by Eric Blake <[email protected]>Quoted 14 lines
---
We can improve the API, to support local_err==NULL, for the case when original request was called with errp==NULL, but for this we'll need more changes, like, pass errp to
NBD_FOREACH_REPLY_CHUNKand save it into iter object...But how to detect it in code? Something like
block/nbd.c +0
-0@@ -1059,8 +1059,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,case
NBD_REPLY_TYPE_BLOCK_STATUS:Quoted 8 lines
if (received) {
nbd_channel_error(s, -EINVAL);
-error_setg(&local_err, "Several BLOCK_STATUS chunks in reply"); -nbd_iter_channel_error(&iter, -EINVAL, &local_err);
+ if (errp) {
+error_setg(&local_err, "Several BLOCK_STATUS chunks in reply"); + }
+nbd_iter_channel_error(&iter, -EINVAL, errp ? &local_err : NULL);No, that's not worth it.
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 11 lines · Vladimir Sementsov-Ogievskiy
Quoted 4 lines
All callers of
nbd_iter_channel_error()pass the address of alocal_errvariable, and only call this function if an error has already occurred, using this functionto append details to that error.
Hmm, not to append details but to report the error to the magical receiving loop, which doesn't yet know about the error
Quoted 1 line
This is already implied by its name (
local_errinstead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.So, how about simply s/to append details to that error/to report that error/ ?
That should be fine.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
In reply to Vladimir Sementsov-OgievskiyQuoted 31 lines · Vladimir Sementsov-Ogievskiy
Quoted 30 lines · Eric Blake
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
block/nbd.c| 1 +1 file changed, 1 insertion(+)block/nbd.c +0
-0block/nbd.c typedef struct NBDReplyChunkIter { · line 869
Quoted 4 lines
block/nbd.c +1
-0@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter { static void nbd_iter_channel_error(NBDReplyChunkIter *iter, int ret, Error **local_err) { + assert(local_err && *local_err);Why are we forbidding grandparent callers from passing NULL when they want to ignore an error? We are called by several parent functions that get an errp from the grandparent, and use this function to do some common grunt work. Let's look at the possibilities:
1. grandparent passes address of a local error: we want to append to the error message, parent will then deal with the error how it wants (report it, ignore it, propagate it, whatever)
2. grandparent passes
&error_fatal: we want to append a hint, but beforeERRP_AUTO_PROPAGATE, the parent has already exited. AfterERRP_AUTO_PROPAGATE, this looks like case 1.3. grandparent passes
&error_abort: we should never be reached (failure earlier in the parent should have already aborted) - true whether or notERRP_AUTO_PROPAGATEis applied
Quoted 8 lines
Quoted 3 lines
4. grandparent passes NULL to ignore the error. Does not currently happen in any of the grandparent callers, because if it did, your assertion in this patch would now fire. After
ERRP_AUTO_PROPAGATE, this would look like case 1.Would it be better to
assert(!local_err || *local_err)? The assertion as written is too strict withoutERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.We don't have any grandparents, this function is always called on
local_err. And it's argument namedlocal_errto stress it. The function is an API to report error, and it wants filledlocal_errobject.It will crash anyway if
local_erris NULL, as it dereferences it.
Yes.
We already assert ret < 0 explicitly, and we rely on !local_err implicitly. Making that explicit is obviously safe.
The code doesn't actually rely on !*local_err. But when ret < 0, and !local_err, surely local_err should point to an Error object. Asserting that makes sense to me.
Quoted 2 lines
I just want to place an assertion at start of functions like this, which will be easily recognizable by coccinelle.
That's not a convincing argument. Doesn't matter as long as we have convincing ones :)
Quoted 26 lines
---
We can improve the API, to support local_err==NULL, for the case when original request was called with errp==NULL, but for this we'll need more changes, like, pass errp to
NBD_FOREACH_REPLY_CHUNKand save it into iter object...But how to detect it in code? Something like
block/nbd.c +4
-2@@ -1059,8 +1059,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,case NBD_REPLY_TYPE_BLOCK_STATUS :if (received) {nbd_channel_error (s, -EINVAL ); -error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); -nbd_iter_channel_error (&iter, -EINVAL , &local_err); +if (errp) { +error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); + } +nbd_iter_channel_error (&iter, -EINVAL , errp ? &local_err :NULL ); } received = true;
Quoted 4 lines
is ugly..
So, to support original errp=NULL the whole thing should be refactored.. Not worth it, I think.
The only change I'd consider in addition to the assertion is this simplification:
block/nbd.c +1 -3
@@ -870,11 +870,9 @@ static void nbd_iter_channel_error(NBDReplyChunkIter *iter,if (!iter->ret) { iter->ret = ret; -error_propagate (&iter->err, *local_err); - }else { -error_free (*local_err); } +error_propagate (&iter->err, *local_err); *local_err =NULL ; }
Re: [PATCH v7 21/21] nbd: assert that Error** is not NULL in nbd_iter_channel_error
Quoted 47 lines · Markus Armbruster
Quoted 31 lines · Vladimir Sementsov-Ogievskiy
Quoted 30 lines · Eric Blake
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
The
local_errparameter is not here to return information aboutnbd_iter_channel_errorfailure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/nbd.c | 1 + 1 file changed, 1 insertion(+)block/nbd.c +0
-0block/nbd.c typedef struct NBDReplyChunkIter { · line 869
Quoted 4 lines
block/nbd.c +1
-0@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter { static void nbd_iter_channel_error(NBDReplyChunkIter *iter, int ret, Error **local_err) { + assert(local_err && *local_err);Why are we forbidding grandparent callers from passing NULL when they want to ignore an error? We are called by several parent functions that get an errp from the grandparent, and use this function to do some common grunt work. Let's look at the possibilities:
1. grandparent passes address of a local error: we want to append to the error message, parent will then deal with the error how it wants (report it, ignore it, propagate it, whatever)
2. grandparent passes
&error_fatal: we want to append a hint, but beforeERRP_AUTO_PROPAGATE, the parent has already exited. AfterERRP_AUTO_PROPAGATE, this looks like case 1.3. grandparent passes
&error_abort: we should never be reached (failure earlier in the parent should have already aborted) - true whether or notERRP_AUTO_PROPAGATEis appliedQuoted 8 lines
Quoted 3 lines
4. grandparent passes NULL to ignore the error. Does not currently happen in any of the grandparent callers, because if it did, your assertion in this patch would now fire. After
ERRP_AUTO_PROPAGATE, this would look like case 1.Would it be better to
assert(!local_err || *local_err)? The assertion as written is too strict withoutERRP_AUTO_PROPAGATE, but you get away with it because none of the grandparents pass NULL; but is appropriate as written for after after the macro conversion so then we wonder if churn on the macro is worth it.We don't have any grandparents, this function is always called on
local_err. And it's argument namedlocal_errto stress it. The function is an API to report error, and it wants filledlocal_errobject.It will crash anyway if
local_erris NULL, as it dereferences it.Yes.
We already assert ret < 0 explicitly, and we rely on !local_err implicitly. Making that explicit is obviously safe.
Quoted 8 lines
The code doesn't actually rely on !*local_err. But when ret < 0, and !local_err, surely
local_errshould point to an Error object. Asserting that makes sense to me.Quoted 2 lines
I just want to place an assertion at start of functions like this, which will be easily recognizable by coccinelle.
That's not a convincing argument.
That's why it is absent in commit message)
Quoted 42 lines
Doesn't matter as long as we have
convincing ones :)Quoted 26 lines
---
We can improve the API, to support local_err==NULL, for the case when original request was called with errp==NULL, but for this we'll need more changes, like, pass errp to
NBD_FOREACH_REPLY_CHUNKand save it into iter object...But how to detect it in code? Something like
block/nbd.c +4
-2@@ -1059,8 +1059,10 @@ static int nbd_co_receive_blockstatus_reply(BDRVNBDState *s,case NBD_REPLY_TYPE_BLOCK_STATUS :if (received) {nbd_channel_error (s, -EINVAL ); -error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); -nbd_iter_channel_error (&iter, -EINVAL , &local_err); +if (errp) { +error_setg (&local_err,"Several BLOCK_STATUS chunks in reply" ); + } +nbd_iter_channel_error (&iter, -EINVAL , errp ? &local_err :NULL ); } received = true;Quoted 4 lines
is ugly..
So, to support original errp=NULL the whole thing should be refactored.. Not worth it, I think.
The only change I'd consider in addition to the assertion is this simplification:
block/nbd.c +0
-0
block/nbd.c static void nbd_iter_channel_error(NBDReplyChunkIter *iter, · line 875
Quoted 9 lines
block/nbd.c +1
-3@@ -870,11 +870,9 @@ static void nbd_iter_channel_error(NBDReplyChunkIter *iter,if (!iter->ret) { iter->ret = ret; -error_propagate (&iter->err, *local_err); - }else { -error_free (*local_err); } +error_propagate (&iter->err, *local_err);
because it will just free the second argument if the first one already set.. OK, will add this.
Quoted 4 lines
block/nbd.c +0
-0*local_err =NULL ; }
Signature · 2 lines
Best regards, Vladimir
Quoted 4 lines · On Thu, 5 Dec 2019 18:19:58 +0300 Vladimir Sementsov-Ogievskiy…
Hi all!
This is the first part of the bit series, which contains mostly simple cleanups.
What's the plan? Should subsystem maintainers pick up individual patches, or will they be merged in one go?
Quoted 11 lines · Cornelia Huck
Quoted 4 lines · On Thu, 5 Dec 2019 18:19:58 +0300 Vladimir Sementsov-Ogievskiy…
Hi all!
This is the first part of the bit series, which contains mostly simple cleanups.
What's the plan? Should subsystem maintainers pick up individual patches, or will they be merged in one go?
The latter. Markus will take them all together.
Signature · 2 lines
Best regards, Vladimir
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Quoted 5 lines · Cornelia Huck
Quoted 2 lines · On Thu, 5 Dec 2019 18:19:58 +0300 Vladimir Sementsov-Ogievskiy…
Hi all!
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
This is the first part of the bit series, which contains mostly simple cleanups.
What's the plan? Should subsystem maintainers pick up individual patches, or will they be merged in one go?
The latter. Markus will take them all together.
Subsystem maintainers are welcome to take truly independent patches through their trees if that's more convenient for them, say because it avoids or reduces the likelihood of conflicts.
Whatever is left I will take through my tree. Me taking everything is slightly easier for me, and results in a more coherent git-log. Neither is serious enough to justify inconveniencing subsystem maintainers.