qemu-s390x
[Top][All Lists]
Advanced

[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>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]