* tests/test-putenv.c (main): Don’t pass a string literal
to a function expecting ‘char *’.
---
 ChangeLog           | 4 ++++
 tests/test-putenv.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a8ed30c4ae..5238067cf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-05-16  Paul Eggert  <egg...@cs.ucla.edu>
 
+       putenv-tests: pacify gcc -Wdiscarded-qualifiers
+       * tests/test-putenv.c (main): Don’t pass a string literal
+       to a function expecting ‘char *’.
+
        alloca-opt-tests: add a ‘volatile’
        * tests/test-alloca-opt.c (func) [HAVE_ALLOCA]:
        Now volatile, to foil whole-program optimization.
diff --git a/tests/test-putenv.c b/tests/test-putenv.c
index 1768e7563a..564c86713a 100644
--- a/tests/test-putenv.c
+++ b/tests/test-putenv.c
@@ -39,7 +39,7 @@ main (void)
 
   /* Verify adding an environment variable.  */
   {
-    ASSERT (putenv ("TEST_VAR=abc") == 0);
+    ASSERT (putenv ((char []) {"TEST_VAR=abc"}) == 0);
     ptr = getenv ("TEST_VAR");
     ASSERT (ptr != NULL);
     ASSERT (STREQ (ptr, "abc"));
@@ -47,13 +47,13 @@ main (void)
 
   /* Verify removing an environment variable.  */
   {
-    ASSERT (putenv ("TEST_VAR") == 0);
+    ASSERT (putenv ((char []) {"TEST_VAR"}) == 0);
     ASSERT (getenv ("TEST_VAR") == NULL);
   }
 
   /* Verify the behavior when removing a variable not in the environment.  */
   {
-    ASSERT (putenv ("TEST_VAR") == 0);
+    ASSERT (putenv ((char []) {"TEST_VAR"}) == 0);
     ASSERT (getenv ("TEST_VAR") == NULL);
   }
 
-- 
2.45.0


Reply via email to