Page MenuHomeFreeBSD

scandir: Fix behavior when no entries match.
ClosedPublic

Authored by des on Jun 20 2025, 4:05 PM.
Tags
None
Referenced Files
F132803278: D50949.diff
Mon, Oct 20, 2:40 AM
Unknown Object (File)
Tue, Oct 7, 7:01 AM
Unknown Object (File)
Sun, Oct 5, 9:07 PM
Unknown Object (File)
Wed, Oct 1, 6:55 AM
Unknown Object (File)
Sep 20 2025, 5:49 PM
Unknown Object (File)
Sep 17 2025, 4:56 AM
Unknown Object (File)
Sep 15 2025, 9:20 PM
Unknown Object (File)
Sep 4 2025, 6:56 PM
Subscribers

Details

Summary

In the previous commit, I removed the initial initialization of the
names array, not realizing that scandir() is expected to return
a non-null (but empty) array of entries if no entries matched.
Restore the historical behavior, document it, and add a test.

Fixes: deeebfdecab5
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Jun 20 2025, 4:05 PM
markj added a subscriber: markj.

Out of curiosity, which applications depended on this? I didn't see any apparent problems in the regression test suite.

This revision is now accepted and ready to land.Jun 20 2025, 4:09 PM
This revision was automatically updated to reflect the committed changes.

Out of curiosity, which applications depended on this?

No idea, but that's how it's always worked in BSD, and the macOS manual page documents this expectation. Neither glibc nor gnulib do this, but they don't document it either. POSIX is silent on this matter. I might submit a request for clarification.

I didn't see any apparent problems in the regression test suite.

Which test suite?

In D50949#1163254, @des wrote:

Out of curiosity, which applications depended on this?

No idea, but that's how it's always worked in BSD, and the macOS manual page documents this expectation. Neither glibc nor gnulib do this, but they don't document it either. POSIX is silent on this matter. I might submit a request for clarification.

I didn't see any apparent problems in the regression test suite.

Which test suite?

I meant the FreeBSD test suite in /usr/tests.

and that's why I added a test case :)