Skip to content

LegacyLogMacroChecker enforces a spelling that cannot achieve its stated goal, and contradicts log.h #4297

Closed

Description

@zackees

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 _F printf-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:

  1. Check argument count instead of spelling. Flag single-argument FL_WARN/FL_WARN_F calls that are not stream chains, since those pay for an sstream to print a literal. That catches the 894 and stops rejecting the 866 that are already correct.
  2. 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.
  3. Keep it and fix log.h, which means the 894 single-argument _F calls 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

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Activity

  1. zackees commented on Sep 10, 2026

    @zackees
    MemberAuthor

    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:

    -  FL_WARN_F("Color profile clears legacy correction/temperature/gamma");
    +  FL_WARN << "Color profile clears legacy correction/temperature/gamma";

    citing "emit warnings through FL_WARN with 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:

    src/fl/channels/options.h:148:13: error: use of undeclared identifier 'FL_WARN'
    

    FL_WARN is not a stream object. log.h:327:

    #define FL_WARN(...) _FL_VA_DISPATCH(_FL_WARN_S, _FL_WARN_M, __VA_ARGS__)(__VA_ARGS__)

    A function-like variadic macro, so FL_WARN << x leaves 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 to log_emit and building an sstream.

    And bash lint passes on the non-compiling form. I applied it and ran lint before building: rc=0. So the checker does not object to FL_WARN followed by << at all — it fires on FL_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.

  2. moved this from Triage to Done in FastLED Trackeron Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions