[PATCH 1/2] Revert "stdlib: Support malloc-managed environ arrays for compatibility"
H.J. Lu
hjl.tools@gmail.com
Fri Jan 24 22:39:20 GMT 2025
On Sat, Jan 25, 2025 at 6:27 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> >> 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;
>
> Yes.
>
> > 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.
>
> But then you can use:
>
> TEST_COMPARE_STRING (valp, "1");
It is
error: tst-setenv-environ.c:32: not true: valp[0] == '1' && valp[1] == '\0'
vs
tst-setenv-environ.c:32: error: string comparison failed
string length: 1 bytes
left (evaluated from valp):
"1"
31
right (evaluated from "2"):
"2"
32
It is hard to say which one is better for this case. But
mine is faster.
> It gives you an even better diagnostic.
>
> Thanks,
> Florian
>
--
H.J.
More information about the Libc-alpha
mailing list