[PATCH 1/2] Revert "stdlib: Support malloc-managed environ arrays for compatibility"
H.J. Lu
hjl.tools@gmail.com
Fri Jan 24 22:19:26 GMT 2025
On Fri, Jan 24, 2025 at 7:31 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > The BZ #32588 test should be standalone, independent of
> > the second patch. Here is the v2 patch with getenv.
>
> Fair enough. I've pushed my revert (only).
>
> > +#include <stdlib.h>
> > +#include <support/check.h>
> > +
> > +extern char **environ;
> > +
> > +int
> > +do_test (void)
> > +{
> > + char *valp;
> > + static char *dummy_environ[] = { NULL };
> > + environ = dummy_environ;
> > + setenv ("A", "1", 0);
> > + valp = getenv ("A");
> > + TEST_VERIFY_EXIT (valp[0] == '1' && valp[1] == '\0');
> > + return 0;
> > +}
> > +
> > +#include <support/test-driver.c>
>
> This looks okay, although it's not clear to me why you do not use
> TEST_COMPARE_STRING. If you want to minimize includes (not unreasonable
> for this test), use
>
> return valp[0] == '1' && valp[1] == '\0';
Did you mean
return valp[0] == '1' && valp[1] == '\0' ? 0 : 1;
But stdlib/tst-setenv-environ.out will be empty when it fails.
TEST_VERIFY_EXIT (valp[0] == '1' && valp[1] == '\0');
tells you what failed.
> and drop <support/check.h>.
>
> Patchwork prefers if patches are posted to new threads, I think.
Will do.
> Thanks,
> Florian
>
--
H.J.
More information about the Libc-alpha
mailing list