[PATCH 1/2] Revert "stdlib: Support malloc-managed environ arrays for compatibility"
Florian Weimer
fweimer@redhat.com
Fri Jan 24 11:03:19 GMT 2025
* H. J. Lu:
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
> We need a test like this.
> diff --git a/stdlib/tst-setenv-environ.c b/stdlib/tst-setenv-environ.c
> new file mode 100644
> index 0000000000..783c0731a7
> --- /dev/null
> +++ b/stdlib/tst-setenv-environ.c
> +int
> +do_test (void)
> +{
> + static char *dummy_environ[] = { NULL };
> + environ = dummy_environ;
> + setenv ("A", "1", 0);
> + return 0;
> +}
Agreed. This is already covered by the tests in the second patch, I
believe:
char **save_environ = environ;
#if DO_MALLOC
environ = xmalloc (sizeof (*environ));
#else
char *environ_array[1];
environ = environ_array;
#endif
*environ = NULL;
TEST_COMPARE (setenv ("tst_environ_change_a", "1", 1), 0);
TEST_COMPARE (setenv ("tst_environ_change_b", "2", 1), 0);
Florian
More information about the Libc-alpha
mailing list