[PATCH 24/39] virStorageBackendZFSRefreshPool: Reduce scope of 'tokens'

Peter Krempa posted 39 patches 4 years, 10 months ago
[PATCH 24/39] virStorageBackendZFSRefreshPool: Reduce scope of 'tokens'
Posted by Peter Krempa 4 years, 10 months ago
Declare it in the loop that actually uses it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/storage/storage_backend_zfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index cab1fd1637..6fed25cf4d 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -216,7 +216,6 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED)
     size_t i;
     g_autoptr(virCommand) cmd = NULL;
     g_auto(GStrv) lines = NULL;
-    g_auto(GStrv) tokens = NULL;
     g_autofree char *name = g_strdup(def->source.name);
     char *tmp;

@@ -246,13 +245,13 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED)
         goto cleanup;

     for (i = 0; lines[i]; i++) {
+        g_auto(GStrv) tokens = NULL;
         size_t count;
         char *prop_name;

         if (STREQ(lines[i], ""))
             continue;

-        g_strfreev(tokens);
         if (!(tokens = virStringSplitCount(lines[i], "\t", 0, &count)))
             goto cleanup;

-- 
2.29.2

Re: [PATCH 24/39] virStorageBackendZFSRefreshPool: Reduce scope of 'tokens'
Posted by Ján Tomko 4 years, 10 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Declare it in the loop that actually uses it.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/storage/storage_backend_zfs.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano