Re: git: cb96a0ef0040 - main - cp: Minor code cleanup.

From: Kyle Evans <kevans_at_freebsd.org>
Date: Fri, 03 Feb 2023 16:11:36 UTC
On Fri, Feb 3, 2023 at 10:08 AM Dag-Erling Smørgrav <des@freebsd.org> wrote:
>
> "Rodney W. Grimes" <freebsd@gndrsh.dnsmgr.net> writes:
> > Wouldnt it now be possible for code in the fts_read path to reference
> > errno unintialized?
>
> Can you provide a test case?
>
> We (cp) only look at errno if fts_read() returns NULL, and that only
> happens after an error (errno is expected to be set) or when we're done
> (fts_read() explicitly sets errno to 0).
>

fts_read() doesn't always set errno to 0; notably, there's a number of
FCHDIR() paths that don't set errno (and the change that added it
mentions that scenario exactly) and will return NULL because of an
error.