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 2) #19

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

Build warning when Compler Warnings = All (Part 2) #19

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 warning is generated -

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

C:\Users\grh\Google Drive\Arduino\libraries\DmxSerial2\src\DMXSerial2.cpp:395:16: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

   if ((channel >= 0) && (channel < _initData->footprint)) {

                ^

This occurs because channel is declared as unsigned int.

The fix is simply to change the statement to

   if (channel < _initData->footprint) {
@g0uus g0uus changed the title Build warning when Compler Warnings = All Build warning when Compler Warnings = All (Part 2) 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

Good suggestion. I added a comment.
This change has no effect on code size - I assume the compiler removed it already during optimization.
150d485

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