]> xenbits.xensource.com Git - libvirt.git/commitdiff
getOldStyleBlockDevice: Adjust formatting
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Jun 2015 11:13:27 +0000 (13:13 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Jun 2015 12:13:39 +0000 (14:13 +0200)
Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_backend_scsi.c

index 3c1bae6b7f5afad21b686dc18d2934f2f3c3d389..ddfbadee88b2c8dd37d5bbf97143f66d372537b4 100644 (file)
@@ -301,27 +301,25 @@ getOldStyleBlockDevice(const char *lun_path ATTRIBUTE_UNUSED,
                        char **block_device)
 {
     char *blockp = NULL;
-    int retval = 0;
+    int retval = -1;
 
     /* old-style; just parse out the sd */
-    blockp = strrchr(block_name, ':');
-    if (blockp == NULL) {
+    if (!(blockp = strrchr(block_name, ':'))) {
         /* Hm, wasn't what we were expecting; have to give up */
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to parse block name %s"),
                        block_name);
-        retval = -1;
+        goto cleanup;
     } else {
         blockp++;
-        if (VIR_STRDUP(*block_device, blockp) < 0) {
-            retval = -1;
-            goto out;
-        }
+        if (VIR_STRDUP(*block_device, blockp) < 0)
+            goto cleanup;
 
         VIR_DEBUG("Block device is '%s'", *block_device);
     }
 
- out:
+    retval = 0;
+ cleanup:
     return retval;
 }