[PATCH 22/23] virStorageBackendLogicalParseVolExtents: Move 'extents' inside the loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's used only inside the loop filling the extents, move it there and
restructure the code so that 'extent.path' doesn't have to be freed.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/storage/storage_backend_logical.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index cffa2c8849..90e7c9e41d 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -128,11 +128,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
     unsigned long long offset;
     unsigned long long size;
     unsigned long long length;
-    virStorageVolSourceExtent extent;
     g_autofree char *regex = NULL;

-    memset(&extent, 0, sizeof(extent));
-
     /* Assume 1 extent (the regex for 'devices' is "(\\S+)") and only
      * check the 'stripes' field if we have a striped, mirror, or one of
      * the raid (raid1, raid4, raid5*, raid6*, or raid10) segtypes in which
@@ -189,11 +186,12 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
      * is the whole matched string.
      */
     for (i = 0; i < nextents; i++) {
-        size_t j;
         g_autofree char *offset_str = NULL;
+        virStorageVolSourceExtent extent;
+        size_t j = (i * 2) + 1;
+
+        memset(&extent, 0, sizeof(extent));

-        j = (i * 2) + 1;
-        extent.path = g_match_info_fetch(info, j);
         offset_str = g_match_info_fetch(info, j + 1);

         if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) {
@@ -201,6 +199,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
                            _("malformed volume extent offset value"));
             goto cleanup;
         }
+
+        extent.path = g_match_info_fetch(info, j);
         extent.start = offset * size;
         extent.end = (offset * size) + length;

@@ -210,7 +210,6 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
     ret = 0;

  cleanup:
-    VIR_FREE(extent.path);
     return ret;
 }

-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux