]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: fix virDomainLeaseIndex logic
authorLuyao Huang <lhuang@redhat.com>
Mon, 15 Dec 2014 06:46:28 +0000 (14:46 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Dec 2014 13:19:38 +0000 (14:19 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1174096

When both parameter have lockspaces present, virDomainLeaseIndex
always returns -1 even there is a lease the same with the one we
check. This is due to broken logic in 'if-else' statement.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index 82ab2aaaac65a76172c6a9a64c390dc3765c16b8..15bf8583c41b88356abf4434f75e1406d10e2ff6 100644 (file)
@@ -11673,13 +11673,15 @@ int virDomainLeaseIndex(virDomainDefPtr def,
 
     for (i = 0; i < def->nleases; i++) {
         vlease = def->leases[i];
-        /* Either both must have lockspaces present which  match.. */
-        if (vlease->lockspace && lease->lockspace &&
-            STRNEQ(vlease->lockspace, lease->lockspace))
-            continue;
+        /* Either both must have lockspaces present which match.. */
+        if (vlease->lockspace && lease->lockspace) {
+            if (STRNEQ(vlease->lockspace, lease->lockspace))
+                continue;
         /* ...or neither must have a lockspace present */
-        if (vlease->lockspace || lease->lockspace)
+        } else if (vlease->lockspace || lease->lockspace) {
             continue;
+        }
+
         if (STREQ(vlease->key, lease->key))
             return i;
     }