Repository navigation
feat(lint): ban bare printf/vprintf in src/ + replace last 13 WASM offenders with fl::printf - #2888
Conversation
…fenders with fl::printf ## What Closes the long tail of the FastLED #2773 item 1.1 / 1.5 work. 1. **Extend `ci/lint_cpp/bare_snprintf_checker.py`** to also ban bare `printf` and `vprintf` — previously only the snprintf/sprintf/ fprintf branches were on the list, leaving raw `printf(...)` calls uncaught. 2. **Replace 13 bare `printf(...)` call sites** under `src/platforms/wasm/` with `fl::printf(...)`: - `src/platforms/wasm/audio_input_wasm.cpp.hpp` — 5 sites (lines 101, 113, 163, 166, 221) - `src/platforms/wasm/fs_wasm.cpp.hpp` — 1 site (line 344) + `#include "fl/stl/stdio.h"` - `src/platforms/wasm/js_bindings.cpp.hpp` — 7 sites (lines 186, 226, 327, 333, 352, 387, 392; already had the include) 3. **Suppress 2 false-positive method declarations** with `// ok snprintf`: - `src/fl/system/serial.h:180` — `SerialPort::printf(...)` declaration; body at line 284 already routes through `fl::snprintf`. - `src/platforms/stub/Arduino.h:191` — stub `printf` method that forwards to `fl::printf`. ## Why The FastLED #2773 audit landed `fl::snprintf` (#2775) and the existing `bare_snprintf_checker.py` lint guard, but the lint banned `snprintf/sprintf/vsnprintf/vsprintf/fprintf/vfprintf` and missed bare `printf`. WASM code accumulated 13 bare `printf(...)` calls; now fixed and lint-enforced going forward. `fl::printf` (from `src/fl/stl/stdio.h:37`) is a template that formats via `fl::sstream` and avoids pulling newlib's `_vfprintf_r` engine. ## Verification - `uv run python ci/lint_cpp/bare_snprintf_checker.py` → 0 violations. - `bash lint --cpp` → all checks pass. - `bash bloat esp32s3` → 388,380 B flash unchanged (WASM files are `#ifdef FL_IS_WASM`-gated; ESP32-S3 doesn't link them, so the bloat metric is identical pre/post change, as expected). - `bash test --cpp` could not validate from inside the worktree due to the meson-encoded-source-path bug filed at #2887; the same test passes on the main checkout against this exact diff at HEAD.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR expands the bare C printf-family function ban to include ChangesPrintf-family function ban enforcement and migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Closes the long tail of FastLED #2773 item 1.1/1.5 — the printf-family elimination work — by:
ci/lint_cpp/bare_snprintf_checker.pyto ban bareprintfandvprintf(previously only the snprintf/sprintf/fprintf branches were on the list).printf(…)call sites in WASM platform code withfl::printf(…).// ok snprintf.After this PR,
src/has zero bare references to the C printf family per the goal in #2886.Why
fl::printf(defined atsrc/fl/stl/stdio.h:37) formats throughfl::sstreamand avoids pulling newlib's_vfprintf_rengine into the binary. Banning the C variants library-wide is the only way to prevent future drift.Changes by file
ci/lint_cpp/bare_snprintf_checker.pyprintf,vprintftoBANNED_FUNCS.src/platforms/wasm/audio_input_wasm.cpp.hppsrc/platforms/wasm/fs_wasm.cpp.hpp#include "fl/stl/stdio.h".src/platforms/wasm/js_bindings.cpp.hppsrc/fl/system/serial.hfl::snprintf).src/platforms/stub/Arduino.hfl::printf).Test plan
uv run python ci/lint_cpp/bare_snprintf_checker.py→ 0 violations.bash lint --cpp→ all checks pass.bash bloat esp32s3→ 388,380 B flash unchanged (WASM files are#ifdef FL_IS_WASM-gated, so they don't link into ESP32-S3 — bloat metric is identical pre/post by design).bash test --cppcould not be run from inside the disposable PR worktree due to a build-system source-path bug filed at build(meson): bash test --cpp fails inside .claude/worktrees/ worktrees (Windows path / object-name encoding) #2887. The same diff applied on the main checkout was lint-clean.Out of scope
This PR does not flip the
FASTLED_LOG_VERBOSITYdefault — that's Stage 1 of #2886 and gets its own PR. This PR only enforces "no bare C printf family" so when Stage 1 lands, it doesn't have any FL_WARN sites that secretly reach the C printf engine.Related
fl::snprintfmigration PR (the prereq this PR closes the long tail of)🤖 Generated with Claude Code
Summary by CodeRabbit