Re: [PATCH 3/9] storage: Invert logic for matchISCSISource

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

 



On Thu, Apr 02, 2015 at 13:39:40 -0400, John Ferlan wrote:
> Invert the logic for better readability/flow and futher separation
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/conf/storage_conf.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index fa7a7f9..e4cb54b 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -2297,18 +2297,19 @@ matchISCSISource(virStoragePoolObjPtr matchpool,
>  {
>      virStoragePoolSourcePtr poolsrc = &matchpool->def->source;
>      virStoragePoolSourcePtr defsrc = &def->source;
> -    if (poolsrc->nhost == 1 && defsrc->nhost == 1) {
> -        if (STREQ(poolsrc->hosts[0].name, defsrc->hosts[0].name)) {
> -            if (poolsrc->initiator.iqn && defsrc->initiator.iqn) {
> -                if (STREQ(poolsrc->initiator.iqn, defsrc->initiator.iqn))
> -                    return true;
> -                else
> -                    return false;
> -            }
> -            return true;
> -        }
> -    }
> -    return false;
> +
> +
> +    /* NB: nhost cannot be > 1 */

Remove this comment ...

> +    if (poolsrc->nhost == 0 || defsrc->nhost == 0)

change the conditions to != 1 so that the comment is redundant.

> +        return false;
> +
> +    if (STRNEQ(poolsrc->hosts[0].name, defsrc->hosts[0].name))
> +        return false;
> +
> +    if (STRNEQ_NULLABLE(poolsrc->initiator.iqn, defsrc->initiator.iqn))
> +        return false;
> +
> +    return true;
>  }

... and squash this together with patches 1 and 2. Doing the refactor
right away is probably better a in this case.

Peter

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]