Skip to content

OIL 41, chapter Functions: host code drops no result without its reason - #127

Merged
theAndreas merged 2 commits into
mainfrom
oil-41-functions-discard
Nov 17, 2026
Merged

theAndreas merged 2 commits into
mainfrom
oil-41-functions-discard

Conversation

@theAndreas

Copy link
Copy Markdown
Owner

Nothing changes for a sketch. Whoever runs the simulator or the control program sees a difference only where something fails that went unnoticed before: a connection that cannot be made non-blocking is closed rather than stopping the sketch, simavr that does not initialize fails the load, and the control program says so in its log if it gets no timer. The library is untouched, and every example has the same flash and RAM as on main.

The fourth pull request of the review of the chapter Functions in OIL item 41, for FN-10 of the coding style, as decided on 2026-11-17: every result dropped on purpose goes to Discard() with its reason, a system call's as well, and one whose failure matters is handled instead.

  • Results of system calls and of wxWidgets that the host code dropped without a word now go to Discard() with the reason beside them; close() once, in a function of the simulator's socket code.
  • What the host code computes or finds, some thirty functions, is marked, so that the compiler reports a result that is lost; what only says whether an action worked is not, as with the library's setters.
  • A reference to the object itself, as std::string::append() returns, or a handle to what was just added, as wxSizer::Add() returns, is no result: the call returns it only to chain calls. AGENTS.md says so, beside the rule.
  • The serial port's Open() hands its setup to a function of its own, as the reasons made it longer than 40 lines.

Checked:

  • make check passes: lint, clang-tidy, every host and AVR test, coverage at 100 % of lines, branches and conditions.
  • A run of clang-tidy that reports every dropped return value, over all host code, finds only chained calls.
  • The control program's window builds; it was not clicked through, and its Windows half was not compiled, as there is no MinGW in the dev container.
  • Not run on hardware; the library does not change.

Every result the simulator, the control program and DocuPictures drop,
a system call's included, goes to Discard() with its reason. Where a
failure matters it is handled instead: a socket that still blocks, or
that would wait without end for a request, is closed rather than polled;
a failed avr_init() fails the load; a matrix that does not start fails
DocuPictures; the control program logs a window without a timer.
What the host code computes or finds is MAXMATRIX_NODISCARD.

A reference to the object itself or a handle to what was just added is
no result; AGENTS.md says so. The serial port's Open() hands its setup to
Configure(), as the reasons made it too long. The library and its sizes
do not change.
@theAndreas
theAndreas merged commit 7c2bdb4 into main Nov 17, 2026
12 checks passed
@theAndreas
theAndreas deleted the oil-41-functions-discard branch November 17, 2026 15:19
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