From 965480f148b2b37374f3d81df741be67455d1c61 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sun, 2 Oct 2011 10:17:33 -0400 Subject: [PATCH] Fixing warnings in Ethernet library (Paul Stoffregen). http://code.google.com/p/arduino/issues/detail?id=208 --- libraries/Ethernet/Dhcp.cpp | 2 +- libraries/Ethernet/Dns.cpp | 10 +++++----- libraries/Ethernet/Dns.h | 2 +- libraries/Ethernet/EthernetServer.cpp | 2 +- libraries/Ethernet/util.h | 2 +- libraries/Ethernet/utility/socket.cpp | 1 - libraries/Ethernet/utility/w5100.cpp | 4 ++-- libraries/SPI/SPI.h | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/libraries/Ethernet/Dhcp.cpp b/libraries/Ethernet/Dhcp.cpp index 29db89098..e7a29323b 100755 --- a/libraries/Ethernet/Dhcp.cpp +++ b/libraries/Ethernet/Dhcp.cpp @@ -243,7 +243,7 @@ uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& tr // Skip to the option part // Doing this a byte at a time so we don't have to put a big buffer // on the stack (as we don't have lots of memory lying around) - for (int i =0; i < (240 - sizeof(RIP_MSG_FIXED)); i++) + for (int i =0; i < (240 - (int)sizeof(RIP_MSG_FIXED)); i++) { _dhcpUdpSocket.read(); // we don't care about the returned byte } diff --git a/libraries/Ethernet/Dns.cpp b/libraries/Ethernet/Dns.cpp index 86fd0177a..b3c1a9dc1 100644 --- a/libraries/Ethernet/Dns.cpp +++ b/libraries/Ethernet/Dns.cpp @@ -252,7 +252,7 @@ uint16_t DNSClient::BuildRequest(const char* aName) } -uint16_t DNSClient::ProcessResponse(int aTimeout, IPAddress& aAddress) +uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress) { uint32_t startTime = millis(); @@ -285,7 +285,7 @@ uint16_t DNSClient::ProcessResponse(int aTimeout, IPAddress& aAddress) uint16_t header_flags = htons(*((uint16_t*)&header[2])); // Check that it's a response to this request if ( ( iRequestId != (*((uint16_t*)&header[0])) ) || - (header_flags & QUERY_RESPONSE_MASK != RESPONSE_FLAG) ) + ((header_flags & QUERY_RESPONSE_MASK) != (uint16_t)RESPONSE_FLAG) ) { // Mark the entire packet as read iUdp.flush(); @@ -310,7 +310,7 @@ uint16_t DNSClient::ProcessResponse(int aTimeout, IPAddress& aAddress) } // Skip over any questions - for (int i =0; i < htons(*((uint16_t*)&header[4])); i++) + for (uint16_t i =0; i < htons(*((uint16_t*)&header[4])); i++) { // Skip over the name uint8_t len; @@ -340,7 +340,7 @@ uint16_t DNSClient::ProcessResponse(int aTimeout, IPAddress& aAddress) // type A answer) and some authority and additional resource records but // we're going to ignore all of them. - for (int i =0; i < answerCount; i++) + for (uint16_t i =0; i < answerCount; i++) { // Skip the name uint8_t len; @@ -407,7 +407,7 @@ uint16_t DNSClient::ProcessResponse(int aTimeout, IPAddress& aAddress) else { // This isn't an answer type we're after, move onto the next one - for (int i =0; i < htons(header_flags); i++) + for (uint16_t i =0; i < htons(header_flags); i++) { iUdp.read(); // we don't care about the returned byte } diff --git a/libraries/Ethernet/Dns.h b/libraries/Ethernet/Dns.h index d4f49769b..6bcb98ab9 100644 --- a/libraries/Ethernet/Dns.h +++ b/libraries/Ethernet/Dns.h @@ -31,7 +31,7 @@ public: protected: uint16_t BuildRequest(const char* aName); - uint16_t ProcessResponse(int aTimeout, IPAddress& aAddress); + uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); IPAddress iDNSServer; uint16_t iRequestId; diff --git a/libraries/Ethernet/EthernetServer.cpp b/libraries/Ethernet/EthernetServer.cpp index 3586dcb51..0308b9261 100644 --- a/libraries/Ethernet/EthernetServer.cpp +++ b/libraries/Ethernet/EthernetServer.cpp @@ -69,7 +69,7 @@ EthernetClient EthernetServer::available() size_t EthernetServer::write(uint8_t b) { - write(&b, 1); + return write(&b, 1); } size_t EthernetServer::write(const uint8_t *buffer, size_t size) diff --git a/libraries/Ethernet/util.h b/libraries/Ethernet/util.h index 220011b8f..5042e82e3 100644 --- a/libraries/Ethernet/util.h +++ b/libraries/Ethernet/util.h @@ -1,7 +1,7 @@ #ifndef UTIL_H #define UTIL_H -#define htons(x) ( (x)<<8 | ((x)>>8)&0xFF ) +#define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) ) #define ntohs(x) htons(x) #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ diff --git a/libraries/Ethernet/utility/socket.cpp b/libraries/Ethernet/utility/socket.cpp index 487584511..f717c0fcb 100644 --- a/libraries/Ethernet/utility/socket.cpp +++ b/libraries/Ethernet/utility/socket.cpp @@ -9,7 +9,6 @@ static uint16_t local_port; */ uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag) { - uint8_t ret; if ((protocol == SnMR::TCP) || (protocol == SnMR::UDP) || (protocol == SnMR::IPRAW) || (protocol == SnMR::MACRAW) || (protocol == SnMR::PPPOE)) { close(s); diff --git a/libraries/Ethernet/utility/w5100.cpp b/libraries/Ethernet/utility/w5100.cpp index aafabaeec..9c748fd20 100644 --- a/libraries/Ethernet/utility/w5100.cpp +++ b/libraries/Ethernet/utility/w5100.cpp @@ -140,7 +140,7 @@ uint8_t W5100Class::write(uint16_t _addr, uint8_t _data) uint16_t W5100Class::write(uint16_t _addr, const uint8_t *_buf, uint16_t _len) { - for (int i=0; i<_len; i++) + for (uint16_t i=0; i<_len; i++) { setSS(); SPI.transfer(0xF0); @@ -166,7 +166,7 @@ uint8_t W5100Class::read(uint16_t _addr) uint16_t W5100Class::read(uint16_t _addr, uint8_t *_buf, uint16_t _len) { - for (int i=0; i<_len; i++) + for (uint16_t i=0; i<_len; i++) { setSS(); SPI.transfer(0x0F); diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index 79c89d4d6..f647d5c89 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -22,7 +22,7 @@ #define SPI_CLOCK_DIV2 0x04 #define SPI_CLOCK_DIV8 0x05 #define SPI_CLOCK_DIV32 0x06 -#define SPI_CLOCK_DIV64 0x07 +//#define SPI_CLOCK_DIV64 0x07 #define SPI_MODE0 0x00 #define SPI_MODE1 0x04