From febcb89c5b11342209b80a88d9f9725ea979500a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 5 Jun 2014 18:19:16 +0200 Subject: [PATCH] Don't reuse 'ret' variable in virStorageBackendProbeTarget To match the convention: ret - current function's return value rc - other function's return values --- src/storage/storage_backend_fs.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 414f2c76fe..172ef16953 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -69,6 +69,7 @@ virStorageBackendProbeTarget(virStorageSourcePtr target, { int fd = -1; int ret = -1; + int rc; virStorageSourcePtr meta = NULL; struct stat sb; @@ -77,17 +78,13 @@ virStorageBackendProbeTarget(virStorageSourcePtr target, if (encryption) *encryption = NULL; - if ((ret = virStorageBackendVolOpen(target->path, &sb, - VIR_STORAGE_VOL_FS_PROBE_FLAGS)) < 0) - goto error; /* Take care to propagate ret, it is not always -1 */ - fd = ret; + if ((rc = virStorageBackendVolOpen(target->path, &sb, + VIR_STORAGE_VOL_FS_PROBE_FLAGS)) < 0) + return rc; /* Take care to propagate rc, it is not always -1 */ + fd = rc; - if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, - &sb, true)) < 0) { + if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb, true) < 0) goto error; - } - - ret = -1; if (S_ISDIR(sb.st_mode)) { target->format = VIR_STORAGE_FILE_DIR; @@ -104,10 +101,13 @@ virStorageBackendProbeTarget(virStorageSourcePtr target, VIR_FORCE_CLOSE(fd); + /* Default to success below this point */ + ret = 0; + if (meta && *backingStore && *backingStoreFormat == VIR_STORAGE_FILE_AUTO && virStorageIsFile(*backingStore)) { - if ((ret = virStorageFileProbeFormat(*backingStore, -1, -1)) < 0) { + if ((rc = virStorageFileProbeFormat(*backingStore, -1, -1)) < 0) { /* If the backing file is currently unavailable, only log an error, * but continue. Returning -1 here would disable the whole storage * pool, making it unavailable for even maintenance. */ @@ -116,11 +116,8 @@ virStorageBackendProbeTarget(virStorageSourcePtr target, *backingStore); ret = -3; } else { - *backingStoreFormat = ret; - ret = 0; + *backingStoreFormat = rc; } - } else { - ret = 0; } if (meta && meta->capacity)