qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] linux-user: preserve incoming order of environment variab


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] linux-user: preserve incoming order of environment variables in the target
Date: Wed, 29 Mar 2023 16:02:52 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 29/3/23 16:00, Daniel P. Berrangé wrote:
On Wed, Mar 29, 2023 at 03:55:13PM +0200, Andreas Schwab wrote:
Do not reverse the order of environment variables in the target environ
array relative to the incoming environ order.  Some testsuites depend on a
specific order, even though it is not defined by any standard.

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
  linux-user/main.c | 6 ++++++
  1 file changed, 6 insertions(+)

bsd-user/main.c appears to have an identical code pattern that
will need the same fix


diff --git a/linux-user/main.c b/linux-user/main.c
index 4b18461969..dbfd3ee8f1 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -691,7 +691,13 @@ int main(int argc, char **argv, char **envp)
      envlist = envlist_create();
/* add current environment into the list */
+    /* envlist_setenv adds to the front of the list; to preserve environ
+       order add from back to front */

Also, QEMU coding style now requires:

  /*
   * this comment form.
   */

;)

      for (wrk = environ; *wrk != NULL; wrk++) {
+        continue;
+    }
+    while (wrk != environ) {
+        wrk--;
          (void) envlist_setenv(envlist, *wrk);
      }
--
2.40.0


--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


With regards,
Daniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]