Skip to content

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

@softhack007

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?

Metadata

Metadata

Assignees

Labels

bugfixed in sourceThis issue is unsolved in the latest release but fixed in master

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions