Re: [PATCH 1/3] tools/nolibc: unistd: Add getcwd()

From: Daniel Palmer

Date: Tue May 05 2026 - 05:12:41 EST


Hi Thomas,

On Sat, 2 May 2026 at 22:41, Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
> > +{
> > + /* If successful we get the number of bytes written into
> > + * the buffer, so check the result is positive.
> > + */
> > + if (__sysret(_sys_getcwd(buf, size)) > 0)
>
> According to the comment before the system call implementation this should be '>= 0'.

I think 0 is an error and the comment I wrote is a bit off. I think it
should be "result is greater than 0".
Anyhow, I wondered what musl and glibc were doing around this as I
couldn't work it out from the manpage.
Long story short I have adjusted this so the logic follows what musl
is doing and I'll send a v2.

Thanks,

Daniel.