diff options
author | John Ferlan <jferlan@redhat.com> | 2015-10-08 13:48:14 -0400 |
---|---|---|
committer | John Ferlan <jferlan@redhat.com> | 2015-10-13 18:03:55 -0400 |
commit | 1059c48180ae888a6c64fd851bdb1ca031fc5502 (patch) | |
tree | f034fa67c488cd2950d4e71b4661e35cff6ed0c0 | |
parent | 21eb897241d94fc40e4db05baec64ae13b422b12 (diff) | |
download | libvirt-1059c48180ae888a6c64fd851bdb1ca031fc5502.tar.gz |
storage: Rework error paths for virStorageBackendCreateExecCommand
Rework the code in order to use the "ret = -1;" and goto cleanup;
coding style.
Signed-off-by: John Ferlan <jferlan@redhat.com>
-rw-r--r-- | src/storage/storage_backend.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index ad7a576fb7..a375fe0f51 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -679,6 +679,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, uid_t uid; mode_t mode; bool filecreated = false; + int ret = -1; if ((pool->def->type == VIR_STORAGE_POOL_NETFS) && (((geteuid() == 0) @@ -703,11 +704,11 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, if (!filecreated) { if (virCommandRun(cmd, NULL) < 0) - return -1; + goto cleanup; if (stat(vol->target.path, &st) < 0) { virReportSystemError(errno, _("failed to create %s"), vol->target.path); - return -1; + goto cleanup; } } @@ -721,7 +722,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, _("cannot chown %s to (%u, %u)"), vol->target.path, (unsigned int) uid, (unsigned int) gid); - return -1; + goto cleanup; } mode = (vol->target.perms->mode == (mode_t) -1 ? @@ -730,9 +731,13 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, virReportSystemError(errno, _("cannot set mode of '%s' to %04o"), vol->target.path, mode); - return -1; + goto cleanup; } - return 0; + + ret = 0; + + cleanup: + return ret; } enum { |