]> xenbits.xensource.com Git - libvirt.git/commitdiff
commandhelper: Remove origenv variable
authorTim Wiederhake <twiederh@redhat.com>
Mon, 1 Feb 2021 11:27:45 +0000 (12:27 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Feb 2021 14:00:53 +0000 (15:00 +0100)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tests/commandhelper.c

index ba5681b7156c5f032cd27f9aadddc608d4fead5f..c2040b76f068c62ae22a779e6b7bda913e15c890 100644 (file)
@@ -60,7 +60,6 @@ static int envsort(const void *a, const void *b)
 int main(int argc, char **argv) {
     size_t i, n;
     int open_max;
-    char **origenv;
     char **newenv = NULL;
     char *cwd;
     FILE *log = fopen(abs_builddir "/commandhelper.log", "w");
@@ -92,23 +91,16 @@ int main(int argc, char **argv) {
         }
     }
 
-    origenv = environ;
-    n = 0;
-    while (*origenv != NULL) {
-        n++;
-        origenv++;
+    for (n = 0; environ[n]; n++) {
     }
 
     if (!(newenv = malloc(sizeof(*newenv) * n)))
         abort();
 
-    origenv = environ;
-    n = i = 0;
-    while (*origenv != NULL) {
-        newenv[i++] = *origenv;
-        n++;
-        origenv++;
+    for (i = 0; i < n; i++) {
+        newenv[i] = environ[i];
     }
+
     qsort(newenv, n, sizeof(newenv[0]), envsort);
 
     for (i = 0; i < n; i++) {