[PATCH 1/2] Revert "stdlib: Support malloc-managed environ arrays for compatibility"

Florian Weimer fweimer@redhat.com
Fri Jan 24 11:31:28 GMT 2025


* 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';

and drop <support/check.h>.

Patchwork prefers if patches are posted to new threads, I think.

Thanks,
Florian



More information about the Libc-alpha mailing list