From 2542eb75bda389d1432eff53fd23a882908753e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Thu, 28 Jan 2016 17:44:33 +0100 Subject: [PATCH] Clean up usage of 'ret' variable 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 | 13 +++++-------- src/uml/uml_driver.c | 5 ++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index c07b642b24..231eccf44d 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -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; } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 3cfa36f558..b0dba5c82d 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -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); -- 2.39.5