From 856ccb5bb74b3b0740f5c45097014a56d9351185 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Fri, 18 Feb 2011 13:31:28 +0000 Subject: [PATCH] Added missing U/UL modifiers to fix 16-bit-arch portability. --- CHANGELOG | 2 +- src/core/dhcp.c | 8 ++++---- src/core/ipv4/icmp.c | 2 +- src/core/ipv4/igmp.c | 2 +- src/core/ipv4/ip.c | 2 +- src/include/ipv4/lwip/ip.h | 8 ++++---- src/include/lwip/tcp.h | 2 +- src/include/netif/etharp.h | 10 +++++----- src/netif/ppp/ppp.c | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e2cb951f..66334319 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -234,7 +234,7 @@ HISTORY ++ Bugfixes: 2011-02-17: Simon Goldschmidt - * ipaddr.c: Fixed constant not being 32 bit. + * many files: Added missing U/UL modifiers to fix 16-bit-arch portability. 2011-01-24: Simon Goldschmidt * sockets.c: Fixed bug #31741: lwip_select seems to have threading problems diff --git a/src/core/dhcp.c b/src/core/dhcp.c index e2f231fc..81b4be27 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -965,11 +965,11 @@ dhcp_bind(struct netif *netif) /* subnet mask not given, choose a safe subnet mask given the network class */ u8_t first_octet = ip4_addr1(&dhcp->offered_ip_addr); if (first_octet <= 127) { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000)); + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xff000000UL)); } else if (first_octet >= 192) { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00)); + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffffff00UL)); } else { - ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000)); + ip4_addr_set_u32(&sn_mask, PP_HTONL(0xffff0000UL)); } } @@ -979,7 +979,7 @@ dhcp_bind(struct netif *netif) /* copy network address */ ip_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask); /* use first host address on network as gateway */ - ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001)); + ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001UL)); } #if LWIP_DHCP_AUTOIP_COOP diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index 02e498d7..32902a52 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -191,7 +191,7 @@ icmp_input(struct pbuf *p, struct netif *inp) ip_addr_copy(iphdr->dest, *ip_current_src_addr()); ICMPH_TYPE_SET(iecho, ICMP_ER); /* adjust the checksum */ - if (iecho->chksum >= PP_HTONS(0xffff - (ICMP_ECHO << 8))) { + if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) { iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1; } else { iecho->chksum += PP_HTONS(ICMP_ECHO << 8); diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index 390a5a74..4e4405e1 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -100,7 +100,7 @@ Steve Reynolds */ #define IGMP_TTL 1 #define IGMP_MINLEN 8 -#define ROUTER_ALERT 0x9404 +#define ROUTER_ALERT 0x9404U #define ROUTER_ALERTLEN 4 /* diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index b5afb5a0..6f248716 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -201,7 +201,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) } /* Incrementally update the IP checksum. */ - if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffff - 0x100)) { + if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffffU - 0x100)) { IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100) + 1); } else { IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100)); diff --git a/src/include/ipv4/lwip/ip.h b/src/include/ipv4/lwip/ip.h index 296e344b..74f501d1 100644 --- a/src/include/ipv4/lwip/ip.h +++ b/src/include/ipv4/lwip/ip.h @@ -122,10 +122,10 @@ struct ip_hdr { PACK_STRUCT_FIELD(u16_t _id); /* fragment offset field */ PACK_STRUCT_FIELD(u16_t _offset); -#define IP_RF 0x8000 /* reserved fragment flag */ -#define IP_DF 0x4000 /* dont fragment flag */ -#define IP_MF 0x2000 /* more fragments flag */ -#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ +#define IP_RF 0x8000U /* reserved fragment flag */ +#define IP_DF 0x4000U /* dont fragment flag */ +#define IP_MF 0x2000U /* more fragments flag */ +#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ /* time to live */ PACK_STRUCT_FIELD(u8_t _ttl); /* protocol*/ diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index a09c5ef7..07dcd10e 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -228,7 +228,7 @@ struct tcp_pcb { u16_t acked; u16_t snd_buf; /* Available buffer space for sending (in bytes). */ -#define TCP_SNDQUEUELEN_OVERFLOW (0xffff-3) +#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */ #if TCP_OVERSIZE diff --git a/src/include/netif/etharp.h b/src/include/netif/etharp.h index a4803ec4..02a3d8bc 100644 --- a/src/include/netif/etharp.h +++ b/src/include/netif/etharp.h @@ -134,11 +134,11 @@ PACK_STRUCT_END /** 5 seconds period */ #define ARP_TMR_INTERVAL 5000 -#define ETHTYPE_ARP 0x0806 -#define ETHTYPE_IP 0x0800 -#define ETHTYPE_VLAN 0x8100 -#define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ -#define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ +#define ETHTYPE_ARP 0x0806U +#define ETHTYPE_IP 0x0800U +#define ETHTYPE_VLAN 0x8100U +#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */ +#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */ /** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables * or known to be 32-bit aligned within the protocol header. */ diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index fdf5e419..0c2d20e8 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -439,7 +439,7 @@ pppInit(void) magicInit(); - subnetMask = PP_HTONL(0xffffff00); + subnetMask = PP_HTONL(0xffffff00UL); for (i = 0; i < NUM_PPP; i++) { /* Initialize each protocol to the standard option set. */