[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 02/22] monitor: make hmp_handle_error return a boolean
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v4 02/22] monitor: make hmp_handle_error return a boolean |
Date: |
Thu, 28 Oct 2021 18:47:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
On 10/28/21 17:54, Daniel P. Berrangé wrote:
> This turns the pattern
>
> if (err) {
> hmp_handle_error(mon, err);
> return;
> }
>
> into
>
> if (hmp_handle_error(mon, err);
> return;
> }
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> hw/core/machine-hmp-cmds.c | 3 +--
> include/monitor/hmp.h | 2 +-
> monitor/hmp-cmds.c | 28 +++++++++++-----------------
> 3 files changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index 76b22b00d6..c356783ab9 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -53,8 +53,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
> HotpluggableCPUList *saved = l;
> CpuInstanceProperties *c;
>
> - if (err != NULL) {
> - hmp_handle_error(mon, err);
> + if (hmp_handle_error(mon, err)) {
> return;
> }
>
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 6bc27639e0..a2cb002a3a 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -16,7 +16,7 @@
>
> #include "qemu/readline.h"
>
> -void hmp_handle_error(Monitor *mon, Error *err);
> +bool 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);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index bcaa41350e..9031cea881 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -62,11 +62,13 @@
> #include <spice/enums.h>
> #endif
>
> -void hmp_handle_error(Monitor *mon, Error *err)
> +bool hmp_handle_error(Monitor *mon, Error *err)
> {
> if (err) {
> error_reportf_err(err, "Error: ");
> + return true;
> }
> + return false;
> }
The usual pattern is to return false on error. Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
- [PATCH v4 00/22] monitor: explicitly permit QMP commands to be added for all use cases, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 01/22] monitor: remove 'info ioapic' HMP command, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 02/22] monitor: make hmp_handle_error return a boolean, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 03/22] docs/devel: rename file for writing monitor commands, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 04/22] docs/devel: tweak headings in monitor command docs, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 05/22] docs/devel: update error handling guidance for HMP commands, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 06/22] monitor: introduce HumanReadableText and HMP support, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 08/22] docs/devel: add example of command returning unstructured text, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 09/22] docs/devel: document expectations for HMP commands in the future, Daniel P . Berrangé, 2021/10/28
- [PATCH v4 07/22] docs/devel: document expectations for QAPI data modelling for QMP, Daniel P . Berrangé, 2021/10/28