Skip to content

[libc] avoid setting errno in src/__support #143937

@michaelrj-google

Description

@michaelrj-google
Contributor

Setting errno in support makes controlling whether errno is set much more difficult. Errno should be set as close to the return of a public function as possible.

List of places that need to be changed:

  • __support/OSUtil/linux/fcntl.cpp - change to returning ErrorOr since if there's an error it always returns -1.
    __support/OSUtil/linux/vdso.cpp - currently calling public functions in support, which is also a problem. Move getauxval to an internal utility that doesn't set errno and this problem goes away.
    __support/HashTable/randomness.h - same issue as vdso, calling public functions leads to setting errno.

Activity

llvmbot

llvmbot commented on Jun 12, 2025

@llvmbot
Member

@llvm/issue-subscribers-libc

Author: Michael Jones (michaelrj-google)

Setting errno in support makes controlling whether errno is set much more difficult. Errno should be set as close to the return of a public function as possible.

List of places that need to be changed:

  • __support/OSUtil/linux/fcntl.cpp - change to returning ErrorOr since if there's an error it always returns -1.
    __support/OSUtil/linux/vdso.cpp - currently calling public functions in support, which is also a problem. Move getauxval to an internal utility that doesn't set errno and this problem goes away.
    __support/HashTable/randomness.h - same issue as vdso, calling public functions leads to setting errno.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @llvmbot@michaelrj-google

        Issue actions

          [libc] avoid setting errno in `src/__support` · Issue #143937 · llvm/llvm-project