patch #6699: fixed some warnings on platform where sizeof(int) == 2

This commit is contained in:
goldsimon 2008-12-19 18:08:29 +00:00
parent 411cb39eb4
commit aa568727d1
9 changed files with 62 additions and 20 deletions

View File

@ -56,6 +56,9 @@ HISTORY
++ Bugfixes:
2008-12-19 Simon Goldschmidt
* many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2
2008-12-10 Tamas Somogyi, Frédéric Bernon
* sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and
port uses deleted netbuf.

View File

@ -952,7 +952,7 @@ do_writemore(struct netconn *conn)
LWIP_ASSERT("conn->state == NETCONN_WRITE", (conn->state == NETCONN_WRITE));
dataptr = (u8_t*)conn->write_msg->msg.w.dataptr + conn->write_offset;
if ((conn->write_msg->msg.w.len - conn->write_offset > 0xffff)) { /* max_u16_t */
if ((conn->write_msg->msg.w.len - conn->write_offset > (int)0xffff)) { /* max_u16_t */
len = 0xffff;
#if LWIP_TCPIP_CORE_LOCKING
conn->write_delayed = 1;

View File

@ -297,11 +297,12 @@ tcpip_thread(void *arg)
case TCPIP_MSG_TIMEOUT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg));
if(msg->msg.tmo.msecs != 0xffffffff)
sys_timeout (msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg);
else
sys_untimeout (msg->msg.tmo.h, msg->msg.tmo.arg);
sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg);
memp_free(MEMP_TCPIP_MSG_API, msg);
break;
case TCPIP_MSG_UNTIMEOUT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: UNTIMEOUT %p\n", (void *)msg));
sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg);
memp_free(MEMP_TCPIP_MSG_API, msg);
break;
@ -379,6 +380,14 @@ tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block)
return ERR_VAL;
}
/**
* call sys_timeout in tcpip_thread
*
* @param msec time in miliseconds for timeout
* @param h function to be called on timeout
* @param arg argument to pass to timeout function h
* @return ERR_MEM on memory error, ERR_OK otherwise
*/
err_t
tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
{
@ -400,6 +409,35 @@ tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
return ERR_VAL;
}
/**
* call sys_untimeout in tcpip_thread
*
* @param msec time in miliseconds for timeout
* @param h function to be called on timeout
* @param arg argument to pass to timeout function h
* @return ERR_MEM on memory error, ERR_OK otherwise
*/
err_t
tcpip_untimeout(u32_t msecs, sys_timeout_handler h, void *arg)
{
struct tcpip_msg *msg;
if (mbox != SYS_MBOX_NULL) {
msg = memp_malloc(MEMP_TCPIP_MSG_API);
if (msg == NULL) {
return ERR_MEM;
}
msg->type = TCPIP_MSG_UNTIMEOUT;
msg->msg.tmo.msecs = msecs;
msg->msg.tmo.h = h;
msg->msg.tmo.arg = arg;
sys_mbox_post(mbox, msg);
return ERR_OK;
}
return ERR_VAL;
}
#if LWIP_NETCONN
/**
* Call the lower part of a netconn_* function

View File

@ -83,7 +83,8 @@ int
inet_aton(const char *cp, struct in_addr *addr)
{
u32_t val;
int base, n, c;
u8_t base;
char c;
u32_t parts[4];
u32_t *pp = parts;
@ -139,8 +140,7 @@ inet_aton(const char *cp, struct in_addr *addr)
* Concoct the address according to
* the number of parts specified.
*/
n = pp - parts + 1;
switch (n) {
switch (pp - parts + 1) {
case 0:
return (0); /* initial nondigit */

View File

@ -107,7 +107,7 @@ lwip_standard_chksum(void *dataptr, u16_t len)
}
/* add deferred carry bits */
acc = (acc >> 16) + (acc & 0x0000ffffUL);
if ((acc & 0xffff0000) != 0) {
if ((acc & 0xffff0000UL) != 0) {
acc = (acc >> 16) + (acc & 0x0000ffffUL);
}
/* This maybe a little confusing: reorder sum using htons()

View File

@ -1316,7 +1316,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
/* Parse the TCP MSS option, if present. */
if(TCPH_HDRLEN(tcphdr) > 0x5) {
for(c = 0; c < (TCPH_HDRLEN(tcphdr) - 5) << 2 ;) {
for(c = 0; c < ((TCPH_HDRLEN(tcphdr) - 5) << 2) ;) {
opt = opts[c];
if (opt == 0x00) {
/* End of options. */

View File

@ -635,9 +635,9 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
}
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
("udp_bind: bound to %"U16_F".%"U16_F".%"U16_F".%"U16_F", port %"U16_F"\n",
(u16_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff),
(u16_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff),
(u16_t)(ntohl(pcb->local_ip.addr) >> 8 & 0xff),
(u16_t)((ntohl(pcb->local_ip.addr) >> 24) & 0xff),
(u16_t)((ntohl(pcb->local_ip.addr) >> 16) & 0xff),
(u16_t)((ntohl(pcb->local_ip.addr) >> 8) & 0xff),
(u16_t)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port));
return ERR_OK;
}
@ -693,9 +693,9 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
#endif
LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
("udp_connect: connected to %"U16_F".%"U16_F".%"U16_F".%"U16_F",port %"U16_F"\n",
(u16_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff),
(u16_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff),
(u16_t)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff),
(u16_t)((ntohl(pcb->remote_ip.addr) >> 24) & 0xff),
(u16_t)((ntohl(pcb->remote_ip.addr) >> 16) & 0xff),
(u16_t)((ntohl(pcb->remote_ip.addr) >> 8) & 0xff),
(u16_t)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port));
/* Insert UDP PCB into the list of active UDP PCBs. */

View File

@ -185,7 +185,7 @@ void tcp_rexmit_rto (struct tcp_pcb *pcb);
#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */
#ifndef TCP_MSL
#define TCP_MSL 60000U /* The maximum segment lifetime in milliseconds */
#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */
#endif
/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */

View File

@ -90,7 +90,7 @@ err_t pbuf_free_callback(struct pbuf *p);
err_t mem_free_callback(void *m);
err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
#define tcpip_untimeout(h, arg) tcpip_timeout(0xffffffff, h, arg)
err_t tcpip_untimeout(u32_t msecs, sys_timeout_handler h, void *arg);
enum tcpip_msg_type {
#if LWIP_NETCONN
@ -101,7 +101,8 @@ enum tcpip_msg_type {
TCPIP_MSG_NETIFAPI,
#endif /* LWIP_NETIF_API */
TCPIP_MSG_CALLBACK,
TCPIP_MSG_TIMEOUT
TCPIP_MSG_TIMEOUT,
TCPIP_MSG_UNTIMEOUT
};
struct tcpip_msg {