]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
patch #6699: fixed some warnings on platform where sizeof(int) == 2
authorgoldsimon <goldsimon>
Fri, 19 Dec 2008 18:08:29 +0000 (18:08 +0000)
committergoldsimon <goldsimon>
Fri, 19 Dec 2008 18:08:29 +0000 (18:08 +0000)
CHANGELOG
src/api/api_msg.c
src/api/tcpip.c
src/core/ipv4/inet.c
src/core/ipv4/inet_chksum.c
src/core/tcp_in.c
src/core/udp.c
src/include/lwip/tcp.h
src/include/lwip/tcpip.h

index 34b1baa29f418542a6546985eeb25cf49872938a..97648f4f35f8026a131d51f845f8d60d24144abd 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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.
index 20c5fd89676e6d1464235e53f5251442bff4ccd9..ce4b5bcb2312a1e7907e1727c4cc2c465df92b9a 100644 (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;
index 29384b698d6a1ada28ac7d81ac9d5169be6c0fb4..5fa4b9580d3cd5ae517fbe2bf6f62a3d5143c5fb 100644 (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
index 24c7ff46919582a0b93595c82abe1e1762f134d1..496aabae41446f06ea11160ee1440012d5c43942 100644 (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 */
index 9248f7d4e3534c1f76e058eb7fe5db74c67412bc..de7b49d1abbee13c7b59f79e9b330f3f022e9034 100644 (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()
index 765ac466d106357ecba26e8f2db553722bc88d50..d58420c4baaaae75e1a2035e935fe9cfb23c0d9d 100644 (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. */
index 2f36c7458775dc47a0fc14639bf0a8671590ec86..0d139b53bd9a35947bc43aecf59bfb2a4abb3089 100644 (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. */
index 883b0b831671eb4fea6a03ea52793796bf00c5c9..35220b37582679ff3edb3b567a51dc2313794c3b 100644 (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 */
index 0d295641aec35bf719f2fcb553b9326d1ff56523..4f5b7f8f28eeda102095138e2cee7092fcdffd44 100644 (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 {