[PATCH] virjson: Change virJSONValueObjectHasKey() signature

Peter Krempa pkrempa at redhat.com
Thu Jul 28 13:50:43 UTC 2022


On Thu, Jul 28, 2022 at 15:33:33 +0200, Michal Privoznik wrote:
> Currently, virJSONValueObjectHasKey() can return one of three
> values:
> 
>   -1 if passed object type is not VIR_JSON_TYPE_OBJECT,
>    0 if the key is not present, and finally
>    1 if the key is present.
> 
> But, neither of callers is interested in the -1 case. In fact,
> some callers call this function treating -1 and 1 cases the same.
> Therefore, make the function return just true/false and fix few
> callers that explicitly checked for == 1 case.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/qemu/qemu_agent.c        |  8 ++++----
>  src/qemu/qemu_monitor_json.c | 10 +++++-----
>  src/util/virjson.c           |  8 ++++----
>  src/util/virjson.h           |  2 +-
>  4 files changed, 14 insertions(+), 14 deletions(-)

You forgot to fix one instance in testQEMUSchemaValidateObjectMandatoryMember
which uses '!= 1' instead of '== 1'.

With that fixed:

Reviewed-by: Peter Krempa <pkrempa at redhat.com>


More information about the libvir-list mailing list