Skip to content

fix(maul): mark the shared cpu.h's two bool functions nodiscard - #126

Merged
siracozmen01 merged 1 commit into
mainfrom
fix/renamed-cpu-nodiscard
Nov 5, 2026
Merged

siracozmen01 merged 1 commit into
mainfrom
fix/renamed-cpu-nodiscard

Conversation

@siracozmen01

Copy link
Copy Markdown
Contributor

Problem

v0.0.53's check_nodiscard.py reports two unmarked bool functions in the shared maul/renamed/src/cpu.h: @P@IsCpuBackendSupported and @P@CheckCpu. #124 marked the other renamed files but missed these, because the @P@ placeholder hid their names from its scan. maul2d, maul3d and maul-anim carry cpu.h and cannot pass the check without editing a family file.

Change

cpu.h includes @LIB@/base.h and marks both declarations @PP@_NODISCARD. A public base.h that also declares them (all three libraries do, unmarked) keeps its own declaration; the mark on this later one makes a dropped result warn inside the library.

Verification

Synced from this branch into scratch trees of maul2d, maul3d and maul-anim:

  • src/cpu.h passes clang-format --dry-run -Werror, and src/cpu.c builds with gcc-14 and clang-20 at -std=c23 -Wall -Wextra -Wpedantic -Werror;
  • tools/check_nodiscard.py no longer reports cpu.h;
  • a call that drops maniCheckCpu's result warns under gcc-14;
  • every call of the two functions in the three libraries (src, tests, bench) uses the result.

Closes #125

@siracozmen01 siracozmen01 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review at ada6ddc: ready. Read, not run.

No cycle. cpu.h now includes @LIB@/base.h. base.h includes only <stdbool.h>, <stddef.h> and <stdint.h> (maul2d's at its sync head, the same shape in the family), never a src/ header, and both have include guards, so the include cannot loop.

No ordering problem.

  • cpu.c includes cpu.h first, as before.
  • For maul2d, maul3d and maul-anim, base.h's unmarked @P@_API bool @P@IsCpuBackendSupported(void); now comes before cpu.h's marked redeclaration, and before the definition in cpu.c. A later declaration may add [[nodiscard]], as the body's gcc-14 and clang-20 runs show.
  • On Windows, a redeclaration without __declspec(dllexport) after one with it keeps the export.

No module rule reached. check_modules.py reads only includes without a slash ("([^"/]+)\.h"), so "@LIB@/base.h" is a public header there, as its comment allows. maul2d's cpu: line needs no new edge.

One effect to know about. cpu.c's definitions now see base.h's @P@_API declaration in the three libraries where it exists. In a shared build that gives @P@IsCpuBackendSupported default visibility (or dllexport) through its definition's own translation unit. That is what @P@_API asks for, but it may change the shared library's export list where the definition was compiled without seeing it. Each library's check_exports test in its sync PR will show it. I did not build a shared tree.

The marks are right: every call in the three libraries uses the result, per the body, and a dropped one now fails at -Werror.

@siracozmen01
siracozmen01 merged commit b52e9f7 into main Nov 5, 2026
1 check failed
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.

The shared cpu.h leaves its two bool functions unmarked

1 participant