From 05909d6fa71bc7721071e931b6e7308d4210424b Mon Sep 17 00:00:00 2001 From: kieranm Date: Wed, 11 Apr 2007 13:32:41 +0000 Subject: [PATCH] Apply patch #5745: Fix "Constant is long" warnings with 16bit compilers. Contributed by avatar@mmlab.cse.yzu.edu.tw --- CHANGELOG | 5 +++++ src/core/inet.c | 6 +++--- src/include/ipv4/lwip/ip_addr.h | 18 +++++++++--------- src/include/lwip/sockets.h | 8 ++++---- src/include/lwip/sys.h | 2 +- src/include/lwip/tcp.h | 8 ++++---- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 06c7dc49..3273d99d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -111,6 +111,11 @@ HISTORY ++ Bug fixes: + 2007-04-11 Kieran Mansley + * inet.c, ip_addr.h, sockets.h, sys.h, tcp.h: Apply patch #5745: Fix + "Constant is long" warnings with 16bit compilers. Contributed by + avatar@mmlab.cse.yzu.edu.tw + 2007-04-05 Frédéric Bernon, Jonathan Larmour * api_msg.c: Fix bug #16830: "err_tcp() posts to connection mailbox when no pend on the mailbox is active". Now, the post is only done during a connect, and do_send, diff --git a/src/core/inet.c b/src/core/inet.c index 2c54389e..95c984d3 100644 --- a/src/core/inet.c +++ b/src/core/inet.c @@ -434,7 +434,7 @@ inet_aton(const char *cp, struct in_addr *addr) break; case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffff) + if (val > 0xffffffUL) return (0); val |= parts[0] << 24; break; @@ -524,8 +524,8 @@ htonl(u32_t n) { return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | - ((n & 0xff0000) >> 8) | - ((n & 0xff000000) >> 24); + ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24); } u32_t diff --git a/src/include/ipv4/lwip/ip_addr.h b/src/include/ipv4/lwip/ip_addr.h index d877ebeb..ce700407 100644 --- a/src/include/ipv4/lwip/ip_addr.h +++ b/src/include/ipv4/lwip/ip_addr.h @@ -78,39 +78,39 @@ extern const struct ip_addr ip_addr_broadcast; #define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any) #define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast) -#define INADDR_NONE ((u32_t)0xffffffff) /* 255.255.255.255 */ -#define INADDR_LOOPBACK ((u32_t)0x7f000001) /* 127.0.0.1 */ +#define INADDR_NONE ((u32_t)0xffffffffUL) /* 255.255.255.255 */ +#define INADDR_LOOPBACK ((u32_t)0x7f000001UL) /* 127.0.0.1 */ /* Definitions of the bits in an Internet address integer. On subnets, host and network parts are found according to the subnet mask, not these masks. */ -#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0) +#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) #define IN_CLASSA_NET 0xff000000 #define IN_CLASSA_NSHIFT 24 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) #define IN_CLASSA_MAX 128 -#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000) +#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) #define IN_CLASSB_NET 0xffff0000 #define IN_CLASSB_NSHIFT 16 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) #define IN_CLASSB_MAX 65536 -#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) #define IN_CLASSC_NET 0xffffff00 #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) -#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ #define IN_MULTICAST(a) IN_CLASSD(a) -#define IN_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000) -#define IN_BADCLASS(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000) +#define IN_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) +#define IN_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) #define IN_LOOPBACKNET 127 /* official! */ @@ -141,7 +141,7 @@ extern const struct ip_addr ip_addr_broadcast; u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *); -#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000)) +#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL)) #define ip_addr_debug_print(debug, ipaddr) \ LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h index bdcd724c..79ea9cd5 100644 --- a/src/include/lwip/sockets.h +++ b/src/include/lwip/sockets.h @@ -177,10 +177,10 @@ typedef struct ip_mreq { * we restrict parameters to at most 128 bytes. */ #if !defined(FIONREAD) || !defined(FIONBIO) -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ +#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000UL /* no parameters */ +#define IOC_OUT 0x40000000UL /* copy out parameters */ +#define IOC_IN 0x80000000UL /* copy in parameters */ #define IOC_INOUT (IOC_IN|IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */ diff --git a/src/include/lwip/sys.h b/src/include/lwip/sys.h index 6a429abc..d631ad1b 100644 --- a/src/include/lwip/sys.h +++ b/src/include/lwip/sys.h @@ -65,7 +65,7 @@ struct sys_timeo {u8_t dummy;}; #include "arch/sys_arch.h" /** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ -#define SYS_ARCH_TIMEOUT 0xffffffff +#define SYS_ARCH_TIMEOUT 0xffffffffUL typedef void (* sys_timeout_handler)(void *arg); diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 4c9227ec..1aaeb370 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -149,7 +149,7 @@ void tcp_rexmit_rto (struct tcp_pcb *pcb); #define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ -#define TCP_MSL 60000 /* The maximum segment lifetime in microseconds */ +#define TCP_MSL 60000U /* The maximum segment lifetime in microseconds */ /* * User-settable options (used with setsockopt). @@ -163,15 +163,15 @@ void tcp_rexmit_rto (struct tcp_pcb *pcb); /* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ #ifndef TCP_KEEPIDLE_DEFAULT -#define TCP_KEEPIDLE_DEFAULT 7200000 /* Default KEEPALIVE timer in milliseconds */ +#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ #endif #ifndef TCP_KEEPINTVL_DEFAULT -#define TCP_KEEPINTVL_DEFAULT 75000 /* Default Time between KEEPALIVE probes in milliseconds */ +#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ #endif #ifndef TCP_KEEPCNT_DEFAULT -#define TCP_KEEPCNT_DEFAULT 9 /* Default Counter for KEEPALIVE probes */ +#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ #endif #define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */