qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v12 16/16] machine: Make smp_parse return a boolean


From: Markus Armbruster
Subject: Re: [PATCH v12 16/16] machine: Make smp_parse return a boolean
Date: Wed, 29 Sep 2021 13:22:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Yanan Wang <wangyanan55@huawei.com> writes:

> Quoting one of the Rules described in include/qapi/error.h:
> "
> Whenever practical, also return a value that indicates success /
> failure.  This can make the error checking more concise, and can
> avoid useless error object creation and destruction.  Note that
> we still have many functions returning void.  We recommend
> • bool-valued functions return true on success / false on failure,
> • pointer-valued functions return non-null / null pointer, and
> • integer-valued functions return non-negative / negative.
> "
>
> So make smp_parse() return true on success and false on failure,
> so that we can more laconically check whether the parsing has
> succeeded without touching the errp.
>
> Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  hw/core/machine.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 4dc936732e..3e3a2707af 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c

[...]

> @@ -933,8 +935,7 @@ static void machine_set_smp(Object *obj, Visitor *v, 
> const char *name,
   {
       MachineState *ms = MACHINE(obj);
       SMPConfiguration *config;
       ERRP_GUARD();

I believe ERRP_GUARD() is now redundant and should be dropped.

       if (!visit_type_SMPConfiguration(v, name, &config, errp)) {
>          return;
>      }
>  
> -    smp_parse(ms, config, errp);
> -    if (*errp) {
> +    if (!smp_parse(ms, config, errp)) {
>          qapi_free_SMPConfiguration(config);
>      }
>  }




reply via email to

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