Skip to content

Codebase review fixes: CMake propagation, asserts, docs, style#3

Merged
DNedic merged 8 commits into
mainfrom
claude/codebase-review-cHBJx
May 19, 2026
Merged

Codebase review fixes: CMake propagation, asserts, docs, style#3
DNedic merged 8 commits into
mainfrom
claude/codebase-review-cHBJx

Conversation

@DNedic
Copy link
Copy Markdown
Owner

@DNedic DNedic commented May 19, 2026

Summary

Fixes from a code review pass, grouped into one commit per concern (documentation fixes consolidated into a single commit).

Correctness

  • fix: propagate LFBB_MULTICORE_HOSTED value and expose configuration as PUBLIC — The previous CMake code added a bare -DLFBB_MULTICORE_HOSTED regardless of the value the user passed, so cmake -DLFBB_MULTICORE_HOSTED=false would still enable multicore mode (the bare macro expands to 1). The defines were also PRIVATE, which meant the struct layout in the header differed between the library build and consumer builds — a silent ABI mismatch when either option was set. Both defines now forward the user-supplied value and are PUBLIC.
  • fix: assert read amount stays within buffer in LFBB_ReadReleaseLFBB_WriteRelease already asserts w + written <= inst->size; add the symmetric check on the read side so misuse is caught in debug builds.
  • fix: reject single-byte buffers in LFBB_Init — A size of 1 produces zero usable capacity because one slot is always reserved to distinguish empty from full. Tighten the assert from size != 0 to size > 1.

Documentation (single commit)

  • README CI badge URL had .github/workflows/ duplicated in the path.
  • README producer example had a missing ) in if (ADC_PollDmaComplete(&adc_dma_h) {.
  • README used triple backticks for inline code spans (not valid CommonMark); switched to single backticks.
  • README claim "single consumer single producer" hyphenated and comma-separated.
  • Typos: README "phenomenom", CHANGELOG "infering", tests "oveflow".
  • lfbb.h @param tags now include parameter names so Doxygen can link them.
  • LFBB_WriteAcquire and LFBB_ReadAcquire now document their NULL return paths.

Style / housekeeping

  • style: use 0U for size_t literal in LFBB_ReadAcquire — only place in the source still using bare 0 for a size_t assignment.
  • chore: drop executable bit on README.md and CHANGELOG.md — they were tracked as 100755 for no reason.
  • chore: bump pre-commit clang-format mirror from v15.0.7 to v19.1.7 — v15 dates from early 2023.

Test plan

  • cmake -B build && cmake --build build && ctest — all 9 tests pass
  • Verified cmake -B build -DLFBB_MULTICORE_HOSTED=true now emits -DLFBB_MULTICORE_HOSTED=true in C_DEFINES (previously emitted bare -DLFBB_MULTICORE_HOSTED)
  • Spot-check that consumers depending on lfbb via CMake now inherit the multicore/cacheline defines (manual)
  • Confirm pre-commit hook works with bumped clang-format version locally

Generated by Claude Code

Comment thread CMakeLists.txt Outdated
add_subdirectory(lfbb)

# Library configuration
# These are exposed as PUBLIC because they affect the layout of LFBB_Inst_Type
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This comment is unnecessary.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Removed in 0a4104e.


Generated by Claude Code

DNedic pushed a commit that referenced this pull request May 19, 2026
claude added 7 commits May 19, 2026 19:52
…s PUBLIC

The previous CMake code added a bare `-DLFBB_MULTICORE_HOSTED` regardless of
the value the user passed, so `cmake -DLFBB_MULTICORE_HOSTED=false` would
still enable multicore mode (the bare macro expands to 1).

The defines were also PRIVATE, which meant the struct layout in the header
differed between the library build and consumer builds — a silent ABI
mismatch when either option was set. Both defines are now PUBLIC and forward
the user-supplied value.
LFBB_WriteRelease already asserts `w + written <= inst->size` to catch
callers releasing more than they acquired. Add the symmetric check on the
read side so misuse is caught in debug builds rather than silently
corrupting the read index.
A size of 1 produces a buffer with zero usable capacity because the
implementation always reserves one slot to distinguish empty from full.
Tighten the assert from `size != 0` to `size > 1` so the degenerate case
is caught at init time.
- README: correct the malformed CI badge URL (duplicated path segment)
- README: fix syntax error in the producer code example (missing ')')
- README: replace inline triple-backtick spans with single backticks
- README: hyphenate "single-producer, single-consumer"
- README: spell "phenomenon" correctly
- CHANGELOG: spell "inferring" correctly
- tests: spell "overflow" correctly in comments
- lfbb.h: name parameters in @param tags so Doxygen can link them
- lfbb.h: document the NULL return path for LFBB_WriteAcquire and
  LFBB_ReadAcquire
The rest of the file consistently uses the `U` suffix for size_t
literals; this assignment to `*available` was the lone exception.
These are plain markdown files; the executable bit was meaningless and
caused them to show up oddly in file managers and `ls -l` output.
v15 dates from early 2023. Move to a current stable release so the
pre-commit hook tracks a modern clang-format with recent fixes.
@DNedic DNedic force-pushed the claude/codebase-review-cHBJx branch from 0a4104e to 058d513 Compare May 19, 2026 19:52
@DNedic DNedic merged commit 4a703de into main May 19, 2026
1 check passed
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