[libvirt] [PATCH 09/12] tests: refactor qemuMonitorTestProcessCommandDefault

Peter Krempa pkrempa at redhat.com
Mon Jun 17 07:07:11 UTC 2019


On Sat, Jun 15, 2019 at 13:54:07 +0200, Ján Tomko wrote:
> Use VIR_AUTOPTR and get rid of the 'ret' variable.
> 
> Signed-off-by: Ján Tomko <jtomko at redhat.com>
> ---
>  tests/qemumonitortestutils.c | 31 +++++++++++--------------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
> index 313ecb01fd..ca678e9bd5 100644
> --- a/tests/qemumonitortestutils.c
> +++ b/tests/qemumonitortestutils.c
> @@ -584,38 +584,29 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
>                                       const char *cmdstr)
>  {
>      struct qemuMonitorTestHandlerData *data = item->opaque;
> -    virJSONValuePtr val = NULL;
> +    VIR_AUTOPTR(virJSONValue) val = NULL;
>      virJSONValuePtr cmdargs = NULL;
>      const char *cmdname;
> -    int ret = -1;
>      int rc;
>  
>      if (!(val = virJSONValueFromString(cmdstr)))
>          return -1;
>  
> -    if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
> -        ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr);
> -        goto cleanup;
> -    }
> +    if (!(cmdname = virJSONValueObjectGetString(val, "execute")))
> +        return qemuMonitorReportError(test, "Missing command name in %s", cmdstr);
>  
>      cmdargs = virJSONValueObjectGet(val, "arguments");
>      if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0)
> -        goto cleanup;
> -
> -    if (rc == 1) {
> -        ret = 0;
> -        goto cleanup;
> -    }
> +        return -1;
> +    if (rc == 1)
> +        return 0;
>  
> -    if (data->command_name && STRNEQ(data->command_name, cmdname))
> -        ret = qemuMonitorTestAddInvalidCommandResponse(test, data->command_name,
> +    if (data->command_name && STRNEQ(data->command_name, cmdname)) {
> +        return qemuMonitorTestAddInvalidCommandResponse(test, data->command_name,
>                                                         cmdname);

Align this line.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190617/7da99acb/attachment-0001.sig>


More information about the libvir-list mailing list