Skip to content

Various errno handling cleanup#259

Merged
fhunleth merged 1 commit into
mainfrom
errno2
Jul 12, 2026
Merged

Various errno handling cleanup#259
fhunleth merged 1 commit into
mainfrom
errno2

Conversation

@fhunleth

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors errno handling in the C NIF layer to centralize errno-to-term translation and to avoid using strerror() strings for exception reasons.

Changes:

  • Introduces make_errno_atom/2 to translate errno values (including -errno return codes) into Erlang atoms, with special-cases for existing custom atoms.
  • Updates NIF read/write paths to raise exceptions using the new errno atom mapping instead of strerror(...).
  • Simplifies make_errno_error/2 by delegating to make_errno_atom/2 (but this changes the error-term shape for “unexpected errors”).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
c_src/nif_utils.c Adds make_errno_atom/2 and refactors errno error construction logic
c_src/gpio_nif.h Exposes make_errno_atom/2 in the NIF utilities header
c_src/gpio_nif.c Uses make_errno_atom/2 for raised exception reasons in read/write NIFs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread c_src/nif_utils.c
@fhunleth
fhunleth merged commit 0bc2eb5 into main Jul 12, 2026
10 checks passed
@fhunleth
fhunleth deleted the errno2 branch July 12, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants