Sfoglia il codice sorgente

Sockets: declare msghdr->msg_iovlen as msg_iovlen_t

* Lwip declares msghdr->msg_iovlen as int, but when
  using external socket headers, some systems declare
  msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
  expects users to typedef it to the type they need
  for their system.
Joan Lledó 6 anni fa
parent
commit
f92d6702bc
3 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. 3 3
      src/api/sockets.c
  2. 3 1
      src/include/lwip/sockets.h
  3. 1 1
      test/unit/api/test_sockets.c

+ 3 - 3
src/api/sockets.c

@@ -1129,7 +1129,7 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16
   u8_t apiflags;
   err_t err;
   u16_t buflen, copylen, copied;
-  int i;
+  msg_iovlen_t i;
 
   LWIP_UNUSED_ARG(dbg_s);
   LWIP_ERROR("lwip_recvfrom_udp_raw: invalid arguments", (msg->msg_iov != NULL) || (msg->msg_iovlen <= 0), return ERR_ARG;);
@@ -1319,7 +1319,7 @@ ssize_t
 lwip_recvmsg(int s, struct msghdr *message, int flags)
 {
   struct lwip_sock *sock;
-  int i;
+  msg_iovlen_t i;
   ssize_t buflen;
 
   LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvmsg(%d, message=%p, flags=0x%x)\n", s, (void *)message, flags));
@@ -1506,7 +1506,7 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags)
 #if LWIP_UDP || LWIP_RAW
   {
     struct netbuf chain_buf;
-    int i;
+    msg_iovlen_t i;
     ssize_t size = 0;
 
     LWIP_UNUSED_ARG(flags);

+ 3 - 1
src/include/lwip/sockets.h

@@ -131,11 +131,13 @@ struct iovec {
 };
 #endif
 
+typedef int msg_iovlen_t;
+
 struct msghdr {
   void         *msg_name;
   socklen_t     msg_namelen;
   struct iovec *msg_iov;
-  int           msg_iovlen;
+  msg_iovlen_t  msg_iovlen;
   void         *msg_control;
   socklen_t     msg_controllen;
   int           msg_flags;

+ 1 - 1
test/unit/api/test_sockets.c

@@ -250,7 +250,7 @@ static void test_sockets_init_loopback_addr(int domain, struct sockaddr_storage
 
 static void test_sockets_msgapi_update_iovs(struct msghdr *msg, size_t bytes)
 {
-  int i;
+  msg_iovlen_t i;
 
   /* note: this modifies the underyling iov_base and iov_len for a partial
      read for an individual vector. This updates the msg->msg_iov pointer