Skip to content

suspicious code in e131.cpp (detect RGB / RGBW) #3236

Closed

Description

@softhack007

This line is a bit suspicious, and I doubt it will work as intended (from #3193)

https://github.com/Aircoookie/WLED/blob/999bec19f1bf37b344177a9aeffc752c5f4ae472/wled00/e131.cpp#L28

Compiler warning:

wled00/e131.cpp:29:57: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   uint8_t ddpChannelsPerLed = (p->dataType & 0b00111000 == 0b011) ? 4 : 3; // data type 0x1B (formerly 0x1A) is RGBW (type 3, 8 bit/channel)
                                              ~~~~~~~~~~~^~~~~~~~

If it is intended as ((p->dataType & 0b00111000) == 0b011), then the decision cannot become true. Any value & 0b00111000 will not have the lowest 3 bits sets, as they are masked out by "&".

Actually I'm not sure how it was indented to work, maybe the original author could take a look?

Activity

  1. blazoncek commented on Jun 7, 2023

    @blazoncek
    Contributor

    It has been fixed in beta-3 branch.

  2. added
    fixed in source
    on Jun 7, 2023
  3. Aircoookie commented on Jun 7, 2023

    @Aircoookie
    Member

    Embarrassing 😅 Well, mistakes happen, thanks for catching it @softhack007 and fixing it promptly @blazoncek :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfixed in source

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions