]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: scsi: invert logic in createVport
authorJán Tomko <jtomko@redhat.com>
Thu, 24 Sep 2020 18:55:24 +0000 (20:55 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 1 Oct 2020 10:34:13 +0000 (12:34 +0200)
Check whether the alloc result is negative (which is
cannot happen with current code) to reduce churn in
the following commit.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/storage/storage_backend_scsi.c

index e528d7622cb21c8fcd030b06959bf9b9e6bd6e86..b5866935d10e341eb2cfc618c114c3cecacce864 100644 (file)
@@ -329,16 +329,17 @@ createVport(virStoragePoolDefPtr def,
      * retry logic set to true. If the thread isn't created, then no big
      * deal since it's still possible to refresh the pool later.
      */
-    if (VIR_ALLOC(cbdata) == 0) {
-        memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
-        cbdata->fchost_name = g_steal_pointer(&name);
-
-        if (virThreadCreateFull(&thread, false, virStoragePoolFCRefreshThread,
-                                "scsi-refresh", false, cbdata) < 0) {
-            /* Oh well - at least someone can still refresh afterwards */
-            VIR_DEBUG("Failed to create FC Pool Refresh Thread");
-            virStoragePoolFCRefreshDataFree(cbdata);
-        }
+    if (VIR_ALLOC(cbdata) < 0)
+        return -1;
+
+    memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN);
+    cbdata->fchost_name = g_steal_pointer(&name);
+
+    if (virThreadCreateFull(&thread, false, virStoragePoolFCRefreshThread,
+                            "scsi-refresh", false, cbdata) < 0) {
+        /* Oh well - at least someone can still refresh afterwards */
+        VIR_DEBUG("Failed to create FC Pool Refresh Thread");
+        virStoragePoolFCRefreshDataFree(cbdata);
     }
 
     return 0;