render / rpms / libvirt

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