[libvirt] [PATCH v2 08/10] qemu: Fix integer/boolean logic in qemuSetUnprivSGIO

Peter Krempa pkrempa at redhat.com
Tue Jul 7 13:13:33 UTC 2015


On Mon, Jul 06, 2015 at 13:08:36 -0400, John Ferlan wrote:
> Setting of 'val' is a boolean expression, so handle it that way and
> adjust the check/return logic to be clearer
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/qemu/qemu_conf.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 5ebf2cc..589a6cf 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1447,7 +1447,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
>      virDomainHostdevDefPtr hostdev = NULL;
>      char *sysfs_path = NULL;
>      const char *path = NULL;
> -    int val = -1;
> +    bool val = false;

No need to initialize val here, since it's written first.

>      int ret = -1;
>  
>      /* "sgio" is only valid for block disk; cdrom
> @@ -1488,8 +1488,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
>       * whitelist is enabled.  But if requesting unfiltered access, always call
>       * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
>       */
> -    if ((virFileExists(sysfs_path) || val == 1) &&
> -        virSetDeviceUnprivSGIO(path, NULL, val) < 0)
> +    if (!val || !virFileExists(sysfs_path)) {
> +        ret = 0;
> +        goto cleanup;
> +    }
> +
> +    if (virSetDeviceUnprivSGIO(path, NULL, 1) < 0)
>          goto cleanup;
>  
>      ret = 0;

ACK,

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150707/7b59293c/attachment-0001.sig>


More information about the libvir-list mailing list