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

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

 



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 */
+    if (poolsrc->nhost == 0 || defsrc->nhost == 0)
+        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;
 }
 
 
-- 
2.1.0

--
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]