render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From c2819b4e2789a1515a10f80e591cdbda1ce6a7d5 Mon Sep 17 00:00:00 2001
Message-Id: <c2819b4e2789a1515a10f80e591cdbda1ce6a7d5@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Fri, 19 Jul 2019 15:34:52 +0200
Subject: [PATCH] util: storage: Clean up label use in
 virStorageFileGetMetadataInternal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The function does not do any cleanup, so replace the 'cleanup' label
with return of -1 and the 'done' label with return of 0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 5b8e64f0bcbbab826cff5be1b0adb000923abfb4)
https: //bugzilla.redhat.com/show_bug.cgi?id=1731329
Message-Id: <c5a7d5884024bc57bde89c2a8a42c65053407c21.1563542241.git.pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virstoragefile.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 52c9dc0e1a..f516a7c7f3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -969,7 +969,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
                                   int *backingFormat)
 {
     int dummy;
-    int ret = -1;
     size_t i;
 
     if (!backingFormat)
@@ -985,7 +984,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
         meta->format >= VIR_STORAGE_FILE_LAST) {
         virReportSystemError(EINVAL, _("unknown storage file meta->format %d"),
                              meta->format);
-        goto cleanup;
+        return -1;
     }
 
     if (fileTypeInfo[meta->format].cryptInfo != NULL) {
@@ -995,7 +994,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
                 int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format;
                 if (!meta->encryption) {
                     if (VIR_ALLOC(meta->encryption) < 0)
-                        goto cleanup;
+                        return -1;
 
                     meta->encryption->format = expt_fmt;
                 } else {
@@ -1004,7 +1003,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
                                        _("encryption format %d doesn't match "
                                          "expected format %d"),
                                        meta->encryption->format, expt_fmt);
-                        goto cleanup;
+                        return -1;
                     }
                 }
                 meta->encryption->payload_offset =
@@ -1017,12 +1016,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
      * code into this method, for non-magic files
      */
     if (!fileTypeInfo[meta->format].magic)
-        goto done;
+        return 0;
 
     /* Optionally extract capacity from file */
     if (fileTypeInfo[meta->format].sizeOffset != -1) {
         if ((fileTypeInfo[meta->format].sizeOffset + 8) > len)
-            goto done;
+            return 0;
 
         if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN)
             meta->capacity = virReadBufInt64LE(buf +
@@ -1033,7 +1032,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
         /* Avoid unlikely, but theoretically possible overflow */
         if (meta->capacity > (ULLONG_MAX /
                               fileTypeInfo[meta->format].sizeMultiplier))
-            goto done;
+            return 0;
         meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier;
     }
 
@@ -1043,25 +1042,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
                                                          backingFormat,
                                                          buf, len);
         if (store == BACKING_STORE_INVALID)
-            goto done;
+            return 0;
 
         if (store == BACKING_STORE_ERROR)
-            goto cleanup;
+            return -1;
     }
 
     if (fileTypeInfo[meta->format].getFeatures != NULL &&
         fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0)
-        goto cleanup;
+        return -1;
 
     if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features &&
         VIR_STRDUP(meta->compat, "1.1") < 0)
-        goto cleanup;
+        return -1;
 
- done:
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
-- 
2.22.1