Repository navigation
Description
Three things disagree
1. src/fl/log/log.h:328 tells new code to drop the suffix:
// _F suffix preserved as alias for backward compatibility (#3272). New code
// should drop the _F suffix and rely on argument-count dispatch.
#define FL_WARN_F(...) FL_WARN(__VA_ARGS__)2. LegacyLogMacroChecker bans the bare form in src/, with "No suppression exists by design":
Bans legacy stream-style FastLED logging macros (FL_WARN, FL_PRINT, FL_DBG, FL_ERROR, FL_LOG_*) in src/. Each call site should use the
_Fprintf-style variant so the formatter lives in fl::printf instead of a fresh fl::sstream chain per call site.
3. The rationale in (2) is not achievable by the spelling. Preprocessed with clang++ -E -P:
void fl_probe_a(unsigned n) { FL_WARN_F("x %u", n); }
void fl_probe_b(unsigned n) { FL_WARN("x %u", n); }void fl_probe_a(unsigned n) { ::fl::detail::log_emit_f( ... "x %u", n); }
void fl_probe_b(unsigned n) { ::fl::detail::log_emit_f( ... "x %u", n); }
Identical, as the macro definition requires — FL_WARN_F is FL_WARN.
The real signal is argument count, and the checker does not look at it
FL_WARN("count " << n) -> log_emit( ..., ::fl::sstream() ... ) <- sstream
FL_WARN("plain literal") -> log_emit( ..., ::fl::sstream() ... ) <- sstream
FL_WARN("count %d", n) -> log_emit_f( ..., "count %d", n ) <- no sstream
One argument builds an fl::sstream; two or more do not. The _F suffix has no bearing on which.
So the checker approves the cost it exists to prevent
Counting every FL_{WARN,ERROR,DBG,PRINT}_F call in src/ (excluding third_party) by whether its argument list has a top-level comma:
| form | count | routes to |
|---|---|---|
_F with a format argument |
866 | log_emit_f — no sstream |
_F with one argument |
894 | log_emit — builds an sstream |
More than half of the population the checker approves is the thing it targets. Examples: src/platforms/ota.cpp.hpp:34, :39, :44, :49.
Meanwhile the checker rejects FL_WARN("count %d", n), which is the form that does avoid the sstream, and which log.h tells you to write.
Why this surfaced
A review on #4290 asked for FL_WARN_F → FL_WARN at src/fl/remote/transport/serial.h:172, correctly citing log.h. Applying it fails bash lint:
src/fl/remote/transport/serial.h:
Line 172: FL_WARN("[RPC] discarded a %u byte line ... [use FL_WARN_F instead of FL_WARN]
So the review and the linter cannot both be satisfied, and the call site stays on _F for now.
What needs deciding
The goal is real — fl::sstream cost is what #2963 is about. Only the signal is wrong. Options, in the order I would consider them:
- Check argument count instead of spelling. Flag single-argument
FL_WARN/FL_WARN_Fcalls that are not stream chains, since those pay for ansstreamto print a literal. That catches the 894 and stops rejecting the 866 that are already correct. - Retire the rule and follow
log.h, treating the sstream question as fl::sstream cost-reduction audit: flip the default so FL_WARN/FL_ERROR are compiled by default #2963's. - Keep it and fix
log.h, which means the 894 single-argument_Fcalls are still unaddressed and the comment stops being true.
I have not changed anything here: (1) is a lint rewrite touching a rule with no suppression and 1,760 call sites in scope, which is a decision rather than a cleanup.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 10, 2026
A second instance, and one correction to the framing above
A review on #4332 asked for this, on a line in
src/fl/channels/options.h:citing "emit warnings through
FL_WARNwith stream-style<<, not printf helpers". So the pull in that direction is real and recurring, which is the substance of this issue.But that particular syntax does not compile, and it is worth recording why, because it is a third spelling nobody has named yet:
FL_WARNis not a stream object.log.h:327:A function-like variadic macro, so
FL_WARN << xleaves the bare identifier with nothing to expand. Stream style here goes inside the parentheses —FL_WARN("count " << n)— which is the form my table above measured as routing tolog_emitand building ansstream.And
bash lintpasses on the non-compiling form. I applied it and ran lint before building: rc=0. So the checker does not object toFL_WARNfollowed by<<at all — it fires onFL_WARN(with arguments. That narrows what the rule actually enforces, and means lint is not a safety net against this suggestion.What this changes about the options
Nothing in the three options, but it sharpens option 1. A checker keyed on argument count would also need to handle the
FL_WARN <<spelling — currently accepted by lint and rejected by the compiler — otherwise a reviewer following the docs writes something that lints clean and fails to build.The call site on #4332 stays on
_F, which is what the linter enforces today.docs(lint): stop LegacyLogMacroChecker claiming a cost the suffix can…