Skip to content

LibC: Improve error handling for unimplemented functions#26514

Closed
po-nuvai wants to merge 1 commit intoSerenityOS:masterfrom
po-nuvai:libc-stub-errno-fix
Closed

LibC: Improve error handling for unimplemented functions#26514
po-nuvai wants to merge 1 commit intoSerenityOS:masterfrom
po-nuvai:libc-stub-errno-fix

Conversation

@po-nuvai
Copy link
Contributor

This PR improves error handling for several unimplemented LibC functions:

  • getpriority()/setpriority(): Set errno to ENOSYS before returning -1
  • chroot(): Set errno to ENOSYS before returning -1
  • nice(): Set errno to ENOSYS and return -1 (was incorrectly returning the incr argument)
  • fnmatch(): Return FNM_NOMATCH instead of 0 (which falsely indicates a match)

These functions now properly indicate they are not implemented by setting errno to ENOSYS, following POSIX conventions.

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Dec 29, 2025
@BuggieBot
Copy link
Member

Hello!

One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why.
Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

Set errno to ENOSYS before returning -1 in getpriority(), setpriority(),
chroot(), and nice() stubs. Also fix nice() to return -1 instead of the
incr argument, and fnmatch() to return FNM_NOMATCH instead of 0.
@po-nuvai po-nuvai force-pushed the libc-stub-errno-fix branch from 0f6d355 to 1e36e9e Compare December 29, 2025 12:59
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html
int fnmatch([[maybe_unused]] char const* pattern, [[maybe_unused]] char const* string, [[maybe_unused]] int flags)
{
dbgln("FIXME: Implement fnmatch()");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep these FIXME dbglns. Having this output makes it easier to debug ports that attempt to use these functions and fail because we don't implement them yet.

@nico nico added ⏳ pr-waiting-for-author PR is blocked by feedback / code changes from the author and removed 👀 pr-needs-review PR needs review from a maintainer or community member labels Dec 29, 2025
@oskar-skog
Copy link
Contributor

oskar-skog commented Dec 30, 2025

According to POSIX, fnmatch should return a non-zero value other than FNM_NOMATCH to indicate an error.
https://pubs.opengroup.org/onlinepubs/9799919799/functions/fnmatch.html

@stale
Copy link

stale bot commented Jan 21, 2026

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@stale stale bot added the stale label Jan 21, 2026
@stale
Copy link

stale bot commented Jan 31, 2026

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

@stale stale bot closed this Jan 31, 2026
@github-actions github-actions bot removed the ⏳ pr-waiting-for-author PR is blocked by feedback / code changes from the author label Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants