Skip to content

Overflow warning in htons() #151

Closed
@habazut

Description

@habazut
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions