Document libc wrapper contract #30
@@ -76,6 +76,10 @@ return convention and the `PREPARE_ERROR` / `FAIL_*` / `SUCCEED_RETURN` pattern.
|
|||||||
Four conventions hold across the whole library, and a new wrapper that breaks one
|
Four conventions hold across the whole library, and a new wrapper that breaks one
|
||||||
of them is wrong even if it compiles and passes:
|
of them is wrong even if it compiles and passes:
|
||||||
|
|
||||||
|
- **Preserve the libc contract unless there is a compelling, documented reason
|
||||||
|
not to.** libc behaviour is the standard to meet. This library changes only
|
||||||
|
the error transport (to `akerror`) and, where libc returns a value, the result
|
||||||
|
shape (through a caller-provided destination pointer).
|
||||||
- **A NULL out-param is a caller error**, not "don't care".
|
- **A NULL out-param is a caller error**, not "don't care".
|
||||||
- **Finding nothing is success** -- searching functions write NULL or zero and
|
- **Finding nothing is success** -- searching functions write NULL or zero and
|
||||||
return NULL.
|
return NULL.
|
||||||
@@ -93,6 +97,11 @@ The build is `-Wall -Wextra` and CI adds `-Werror`. `-Wpedantic` is deliberately
|
|||||||
off: libakerror's `FAIL_*` macros trip "ISO C99 requires at least one argument
|
off: libakerror's `FAIL_*` macros trip "ISO C99 requires at least one argument
|
||||||
for the ..." on their own expansion, not on anything at the call site.
|
for the ..." on their own expansion, not on anything at the call site.
|
||||||
|
|
||||||
|
**Do not wrap a libc function that cannot fail and provides no failure or
|
||||||
|
operation-status result.** There is no `akerror` context to carry. A value such
|
||||||
|
as `umask()`'s previous mask is not an operation-status result, so `umask()` is
|
||||||
|
not a wrapper candidate.
|
||||||
|
|
||||||
## Testing Guidelines
|
## Testing Guidelines
|
||||||
|
|
||||||
Add a new test by creating `tests/test_mything.c` and adding `mything` to the
|
Add a new test by creating `tests/test_mything.c` and adding `mything` to the
|
||||||
|
|||||||
Reference in New Issue
Block a user