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

Build warning when Compler Warnings = All (Part 3) #20

Closed
g0uus opened this issue Oct 15, 2018 · 2 comments
Closed

Build warning when Compler Warnings = All (Part 3) #20

g0uus opened this issue Oct 15, 2018 · 2 comments

Comments

@g0uus
Copy link

g0uus commented Oct 15, 2018

If the Arduino Compiler Warnings option is set to YES, the following warnings are generated -

C:\Users\grh\Google Drive\Arduino\libraries\DmxSerial2\src\DMXSerial2.cpp: In member function 'void DMXSerialClass2::write(int, uint8_t)':

C:\Users\grh\Google Drive\Arduino\libraries\DmxSerial2\src\DMXSerial2.cpp:411:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]

   if (value < DMXSERIAL_MIN_SLOT_VALUE) value = DMXSERIAL_MIN_SLOT_VALUE;

             ^

C:\Users\grh\Google Drive\Arduino\libraries\DmxSerial2\src\DMXSerial2.cpp:412:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]

   if (value > DMXSERIAL_MAX_SLOT_VALUE) value = DMXSERIAL_MAX_SLOT_VALUE;

             ^

The problem here is that value is declared as uint8_t and can thus never be less than DMXSERIAL_MIN_SLOT_VALUE or greater than DMXSERIAL_MAX_SLOT_VALUE

The fix is to simply remove or comment out the two if statements.

@g0uus g0uus changed the title Build warnings (part 3) Build warning when Compler Warnings = All (Part 3) Oct 15, 2018
@peternewman
Copy link
Contributor

See the discussion here #18 (comment)

In this case you probably want to add a comment saying what the old test was and maybe why it's been removed.

@mathertel
Copy link
Owner

I commented out with a comment.
66ed0cf

No effect on code size. I assume the compiler already removed them during optimization.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants