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

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



Invert the logic for better readability/flow and futher separation

Signed-off-by: John Ferlan <jferlan redhat com>
---
 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


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