[PATCH 1/2] Revert "stdlib: Support malloc-managed environ arrays for compatibility"
H.J. Lu
hjl.tools@gmail.com
Fri Jan 24 11:22:17 GMT 2025
On Fri, Jan 24, 2025 at 7:03 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * 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
>
The BZ #32588 test should be standalone, independent of
the second patch. Here is the v2 patch with getenv.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-stdlib-Test-using-setenv-with-updated-environ-BZ-.patch
Type: text/x-patch
Size: 2258 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250124/dca97084/attachment-0001.bin>
More information about the Libc-alpha
mailing list