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: Daniel P . Berrangé
Subject: Re: [PATCH v4 02/22] monitor: make hmp_handle_error return a boolean
Date: Mon, 1 Nov 2021 15:54:42 +0000
User-agent: Mutt/2.0.7 (2021-05-04)

On Thu, Oct 28, 2021 at 06:47:38PM +0200, Philippe Mathieu-Daudé wrote:
> 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,

NB That pattern is for functions which are setting errors
via an Error **errp output parameter.

This function is for checking whether an error is set and
reporting message to console, via an Error *err input
parameter.

> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

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