]> xenbits.xensource.com Git - libvirt.git/commitdiff
iscsi_direct: Make virStorageBackendISCSIDirectGetLun report error properly
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 6 Mar 2019 14:27:55 +0000 (15:27 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Sat, 16 Mar 2019 06:50:51 +0000 (07:50 +0100)
This function reports error for one of the two error paths. This
is unfortunate as a caller see this function failing but doesn't
know right away if an error was reported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/storage/storage_backend_iscsi_direct.c

index 786663534d55a57d7461df86c7ea02e79a8d97dc..fc3b6550f741782cb701700c2d39fc056faf11ff 100644 (file)
@@ -605,22 +605,16 @@ static int
 virStorageBackendISCSIDirectGetLun(virStorageVolDefPtr vol,
                                    int *lun)
 {
-    const char *name = vol->name;
-    int ret = -1;
+    const char *name;
 
-    if (!STRPREFIX(name, VOL_NAME_PREFIX)) {
+    if (!(name = STRSKIP(vol->name, VOL_NAME_PREFIX)) ||
+        virStrToLong_i(name, NULL, 10, lun) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid volume name %s"), name);
-        goto cleanup;
+                       _("Invalid volume name %s"), vol->name);
+        return -1;
     }
 
-    name += strlen(VOL_NAME_PREFIX);
-    if (virStrToLong_i(name, NULL, 10, lun) < 0)
-        goto cleanup;
-
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int