|
|
99cbc7 |
From c2819b4e2789a1515a10f80e591cdbda1ce6a7d5 Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <c2819b4e2789a1515a10f80e591cdbda1ce6a7d5@dist-git>
|
|
|
99cbc7 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
99cbc7 |
Date: Fri, 19 Jul 2019 15:34:52 +0200
|
|
|
99cbc7 |
Subject: [PATCH] util: storage: Clean up label use in
|
|
|
99cbc7 |
virStorageFileGetMetadataInternal
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
The function does not do any cleanup, so replace the 'cleanup' label
|
|
|
99cbc7 |
with return of -1 and the 'done' label with return of 0.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 5b8e64f0bcbbab826cff5be1b0adb000923abfb4)
|
|
|
99cbc7 |
https: //bugzilla.redhat.com/show_bug.cgi?id=1731329
|
|
|
99cbc7 |
Message-Id: <c5a7d5884024bc57bde89c2a8a42c65053407c21.1563542241.git.pkrempa@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/util/virstoragefile.c | 27 +++++++++++----------------
|
|
|
99cbc7 |
1 file changed, 11 insertions(+), 16 deletions(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
99cbc7 |
index 52c9dc0e1a..f516a7c7f3 100644
|
|
|
99cbc7 |
--- a/src/util/virstoragefile.c
|
|
|
99cbc7 |
+++ b/src/util/virstoragefile.c
|
|
|
99cbc7 |
@@ -969,7 +969,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
int *backingFormat)
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
int dummy;
|
|
|
99cbc7 |
- int ret = -1;
|
|
|
99cbc7 |
size_t i;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (!backingFormat)
|
|
|
99cbc7 |
@@ -985,7 +984,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
meta->format >= VIR_STORAGE_FILE_LAST) {
|
|
|
99cbc7 |
virReportSystemError(EINVAL, _("unknown storage file meta->format %d"),
|
|
|
99cbc7 |
meta->format);
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (fileTypeInfo[meta->format].cryptInfo != NULL) {
|
|
|
99cbc7 |
@@ -995,7 +994,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format;
|
|
|
99cbc7 |
if (!meta->encryption) {
|
|
|
99cbc7 |
if (VIR_ALLOC(meta->encryption) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
meta->encryption->format = expt_fmt;
|
|
|
99cbc7 |
} else {
|
|
|
99cbc7 |
@@ -1004,7 +1003,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
_("encryption format %d doesn't match "
|
|
|
99cbc7 |
"expected format %d"),
|
|
|
99cbc7 |
meta->encryption->format, expt_fmt);
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
meta->encryption->payload_offset =
|
|
|
99cbc7 |
@@ -1017,12 +1016,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
* code into this method, for non-magic files
|
|
|
99cbc7 |
*/
|
|
|
99cbc7 |
if (!fileTypeInfo[meta->format].magic)
|
|
|
99cbc7 |
- goto done;
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
/* Optionally extract capacity from file */
|
|
|
99cbc7 |
if (fileTypeInfo[meta->format].sizeOffset != -1) {
|
|
|
99cbc7 |
if ((fileTypeInfo[meta->format].sizeOffset + 8) > len)
|
|
|
99cbc7 |
- goto done;
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN)
|
|
|
99cbc7 |
meta->capacity = virReadBufInt64LE(buf +
|
|
|
99cbc7 |
@@ -1033,7 +1032,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
/* Avoid unlikely, but theoretically possible overflow */
|
|
|
99cbc7 |
if (meta->capacity > (ULLONG_MAX /
|
|
|
99cbc7 |
fileTypeInfo[meta->format].sizeMultiplier))
|
|
|
99cbc7 |
- goto done;
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
@@ -1043,25 +1042,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
backingFormat,
|
|
|
99cbc7 |
buf, len);
|
|
|
99cbc7 |
if (store == BACKING_STORE_INVALID)
|
|
|
99cbc7 |
- goto done;
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (store == BACKING_STORE_ERROR)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (fileTypeInfo[meta->format].getFeatures != NULL &&
|
|
|
99cbc7 |
fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features &&
|
|
|
99cbc7 |
VIR_STRDUP(meta->compat, "1.1") < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
+ return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
- done:
|
|
|
99cbc7 |
- ret = 0;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- cleanup:
|
|
|
99cbc7 |
- return ret;
|
|
|
99cbc7 |
+ return 0;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.22.1
|
|
|
99cbc7 |
|