The setenv module's code, shared with glibc, contains an unnecessary
cast from 'char **' to 'char *'. Probably it was once needed for pre-ANSI C
systems, when the type 'void *' did not exist and memcpy() took a 'char *'
as first argument. This is long obsolete.


2024-06-05  Bruno Haible  <br...@clisp.org>

        setenv: Modernize.
        * lib/setenv.c (__add_to_environ): Remove unnecessary casts.

diff --git a/lib/setenv.c b/lib/setenv.c
index 9e2e9e2f0f..2c26734ea1 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -215,8 +215,7 @@ __add_to_environ (const char *name, const char *value, 
const char *combined,
         }
 
       if (__environ != last_environ)
-        memcpy ((char *) new_environ, (char *) __environ,
-                size * sizeof (char *));
+        memcpy (new_environ, __environ, size * sizeof (char *));
 
       new_environ[size + 1] = NULL;
 




Reply via email to