Skip to content

chore(api): audit mutable pointer shape for set_input_gamut #3234

Closed

Description

@zackees

Context

While implementing #3233, the existing RGBW input gamut API surfaced this signature shape:

void set_input_gamut(DiodeProfile* profile, InputGamut g, ...);

FastLED generally shies away from mutable pointer parameters when the parameter is required. A mutable pointer implies nullable / optional semantics and forces every call path to reason about nullptr. Where mutation is required and null is not meaningful, a mutable reference (DiodeProfile&) is usually clearer. Where mutation is not required, const DiodeProfile& is preferred.

This follow-up should decide whether set_input_gamut really needs nullable pointer semantics or whether the public/internal API should be tightened.

Proposal

Audit set_input_gamut(DiodeProfile* profile, ...) and related CFastLED wrappers/callers.

Questions to answer:

  • Is nullptr an intentional no-op API contract, or just defensive implementation detail?
  • If null is not a meaningful user-facing operation, should the API become DiodeProfile& profile?
  • If the function only needs read access in any overload, should that path use const DiodeProfile& instead?
  • Should the CFastLED wrapper keep nullable behavior while an internal helper uses references?
  • What migration path avoids breaking sketches unnecessarily?

Acceptance criteria

  • All set_input_gamut declarations, definitions, wrappers, and call sites are audited.
  • The issue is resolved by either:
    • converting required mutable profile parameters to DiodeProfile&, or
    • documenting why nullable DiodeProfile* is intentional and keeping the current shape.
  • Tests or compile coverage are updated if the API shape changes.
  • Agent review docs are updated if this becomes a broader FastLED rule for mutable pointer parameters.

Related

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