From 15cd8edb6ec9aed2585e10456d46eec09d5c1b8b Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Thu, 16 May 2024 22:40:59 -0700 Subject: [PATCH] putenv-tests: pacify gcc -Wdiscarded-qualifiers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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 <eggert@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.39.5