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

Overflow warning in htons() #151

Closed
habazut opened this issue Sep 27, 2020 · 3 comments · Fixed by #161
Closed

Overflow warning in htons() #151

habazut opened this issue Sep 27, 2020 · 3 comments · Fixed by #161
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@habazut
Copy link

habazut commented Sep 27, 2020

In file included from /usr/share/arduino-1.8.13/libraries/Ethernet/src/Dns.cpp:8:0:
/usr/share/arduino-1.8.13/libraries/Ethernet/src/Dns.cpp: In member function 'uint16_t DNSClient::BuildRequest(const char*)':
/usr/share/arduino-1.8.13/libraries/Ethernet/src/utility/w5100.h:457:25: warning: result of '(256 << 8)' requires 18 bits to represent, but 'int' only has 16 bits [-Wshift-overflow=]
 #define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )

+++ Set a pragma to locally turn of that warning if you know about the overflow and it's OK. +++

Your library shall compile without warnings.

Regards,
Harald.

@jmnc2
Copy link

jmnc2 commented Jan 7, 2021

Is this lib not getting bug fixes any more?

ps. how do you set the pragma? O_o

@habazut
Copy link
Author

habazut commented Jan 31, 2021

Suggestion:

#define htons(x) ( ((( x )&0xFF)<<8) | ((( x )&0xFF00)>>8) )

and for #pragma see google.

Regards,
Harald.

lathoub added a commit to lathoub/Ethernet that referenced this issue Feb 2, 2021
arduino-libraries#151
arduino-libraries#140

#define MAX_SOCK_NUM 4
#define ETHERNET_LARGE_BUFFERS
@gudnimg
Copy link
Contributor

gudnimg commented Apr 19, 2021

I am seeing this also:

image

@per1234 per1234 added conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants