]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: fold setenv() in single block(ish)
authorEmil Velikov <emil.l.velikov@gmail.com>
Fri, 13 Feb 2026 19:52:35 +0000 (19:52 +0000)
committerLucas De Marchi <demarchi@kernel.org>
Wed, 22 Apr 2026 13:40:13 +0000 (08:40 -0500)
... to make it stand out from all the realloc/copying.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/429
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
testsuite/testsuite.c

index 7d20a2b7b7c613d80c925bb39fd36e8d25f9fc33..7dd6fe228a96c09a33e049d3b25e06ba8632ab2e 100644 (file)
@@ -181,8 +181,6 @@ static void test_export_environ(const struct test *t)
                if (t->config[i] == NULL)
                        continue;
 
-               setenv(env_config[i].key, t->config[i], 1);
-
                ldpreload = env_config[i].ldpreload;
                ldpreloadlen = strlen(ldpreload);
                tmp = realloc(preload, preloadlen + 2 + ldpreloadlen);
@@ -221,6 +219,13 @@ static void test_export_environ(const struct test *t)
                setenv("LD_PRELOAD", preload, 1);
        }
 
+       for (i = 0; i < _TC_LAST; i++) {
+               if (t->config[i] == NULL)
+                       continue;
+
+               setenv(env_config[i].key, t->config[i], 1);
+       }
+
        for (env = t->env_vars; env && env->key; env++)
                setenv(env->key, env->val, 1);
 }