]> xenbits.xensource.com Git - libvirt.git/commitdiff
Clean up usage of 'ret' variable
authorJán Tomko <jtomko@redhat.com>
Thu, 28 Jan 2016 16:44:33 +0000 (17:44 +0100)
committerJán Tomko <jtomko@redhat.com>
Thu, 11 Feb 2016 07:05:16 +0000 (08:05 +0100)
Do not store the return value of called functions in the same variable
as the (future) return value of the current function.

This makes tracking the origin of the value easier and reduces
the chance of introducing a new point of exit without resetting
the return value back to -1.

src/storage/storage_backend.c
src/uml/uml_driver.c

index c07b642b24854f3ecbf05df18732e496ea740806..231eccf44d66ba2ea09278e06950b740043dc933 100644 (file)
@@ -1963,26 +1963,23 @@ virStorageBackendVolZeroSparseFileLocal(virStorageVolDefPtr vol,
                                         off_t size,
                                         int fd)
 {
-    int ret = -1;
-
-    ret = ftruncate(fd, 0);
-    if (ret == -1) {
+    if (ftruncate(fd, 0) < 0) {
         virReportSystemError(errno,
                              _("Failed to truncate volume with "
                                "path '%s' to 0 bytes"),
                              vol->target.path);
-        return ret;
+        return -1;
     }
 
-    ret = ftruncate(fd, size);
-    if (ret == -1) {
+    if (ftruncate(fd, size) < 0) {
         virReportSystemError(errno,
                              _("Failed to truncate volume with "
                                "path '%s' to %ju bytes"),
                              vol->target.path, (uintmax_t)size);
+        return -1;
     }
 
-    return ret;
+    return 0;
 }
 
 
index 3cfa36f558b7398bcc28d9e41863f2e049d41cb5..b0dba5c82d2285113ad95752f086d3629cc635a1 100644 (file)
@@ -1131,12 +1131,11 @@ static int umlStartVMDaemon(virConnectPtr conn,
     virCommandSetErrorFD(cmd, &logfd);
     virCommandDaemonize(cmd);
 
-    ret = virCommandRun(cmd, NULL);
-    if (ret < 0)
+    if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
     if (autoDestroy &&
-        (ret = umlProcessAutoDestroyAdd(driver, vm, conn)) < 0)
+        umlProcessAutoDestroyAdd(driver, vm, conn) < 0)
         goto cleanup;
 
     ret = virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm, false);