Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
softhack007 opened this issue Jun 7, 2023 · 2 comments
Closed

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

softhack007 opened this issue Jun 7, 2023 · 2 comments
Assignees
Labels
bug fixed in source This issue is unsolved in the latest release but fixed in master

Comments

@softhack007
Copy link
Collaborator

softhack007 commented Jun 7, 2023

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

uint8_t ddpChannelsPerLed = (p->dataType & 0b00111000 == 0b011) ? 4 : 3; // data type 0x1B (formerly 0x1A) is RGBW (type 3, 8 bit/channel)

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?

@softhack007 softhack007 added the bug label Jun 7, 2023
@blazoncek
Copy link
Collaborator

It has been fixed in beta-3 branch.

@blazoncek blazoncek added the fixed in source This issue is unsolved in the latest release but fixed in master label Jun 7, 2023
@Aircoookie
Copy link
Owner

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

@blazoncek blazoncek mentioned this issue Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in source This issue is unsolved in the latest release but fixed in master
Projects
None yet
Development

No branches or pull requests

3 participants