Преглед изворни кода

Fixed build with MSVC, fixed compiler warnings

Evgeny Grin (Karlson2k) пре 4 година
родитељ
комит
ba5174d488
3 измењених фајлова са 7 додато и 4 уклоњено
  1. 3 0
      src/microhttpd/internal.h
  2. 1 1
      src/microhttpd/mhd_send.c
  3. 3 3
      src/microhttpd/response.c

+ 3 - 0
src/microhttpd/internal.h

@@ -357,6 +357,7 @@ typedef struct _MHD_W32_iovec
   char *iov_base;
 } MHD_iovec_;
 #define MHD_IOV_ELMN_MAX_SIZE    ULONG_MAX
+typedef unsigned long MHD_iov_size_;
 #elif defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
 /**
  * Internally used I/O vector type for use when writev or sendmsg
@@ -364,6 +365,7 @@ typedef struct _MHD_W32_iovec
  */
 typedef struct iovec MHD_iovec_;
 #define MHD_IOV_ELMN_MAX_SIZE    SIZE_MAX
+typedef size_t MHD_iov_size_;
 #else
 /**
  * Internally used I/O vector type for use when writev or sendmsg
@@ -371,6 +373,7 @@ typedef struct iovec MHD_iovec_;
  */
 typedef struct MHD_IoVec MHD_iovec_;
 #define MHD_IOV_ELMN_MAX_SIZE    SIZE_MAX
+typedef size_t MHD_iov_size_;
 #endif
 
 

+ 1 - 1
src/microhttpd/mhd_send.c

@@ -1511,7 +1511,7 @@ send_iov_nontls (struct MHD_Connection *connection,
       /* The last iov element has been partially sent */
       r_iov->iov[r_iov->sent].iov_base =
         (void*) ((uint8_t*) r_iov->iov[r_iov->sent].iov_base + (size_t) res);
-      r_iov->iov[r_iov->sent].iov_len -= res;
+      r_iov->iov[r_iov->sent].iov_len -= (MHD_iov_size_) res;
     }
   }
 

+ 3 - 3
src/microhttpd/response.c

@@ -961,12 +961,12 @@ MHD_create_response_from_iovec (const struct MHD_IoVec *iov,
     for (i = 0; i < iovcnt; ++i)
     {
       size_t element_size = iov[i].iov_len;
-      const void *buf = iov[i].iov_base;
+      const uint8_t *buf = (const uint8_t *) iov[i].iov_base;
 
       if (0 == element_size)
         continue;         /* skip zero-sized elements */
 #if defined(MHD_WINSOCK_SOCKETS) && defined(_WIN64)
-      while (ULONG_MAX < element_size)
+      while (MHD_IOV_ELMN_MAX_SIZE < element_size)
       {
         iov_copy[i_cp].iov_base = (char *) buf;
         iov_copy[i_cp].iov_len = ULONG_MAX;
@@ -976,7 +976,7 @@ MHD_create_response_from_iovec (const struct MHD_IoVec *iov,
       }
 #endif /* MHD_WINSOCK_SOCKETS && _WIN64 */
       iov_copy[i_cp].iov_base = (void *) buf;
-      iov_copy[i_cp].iov_len = element_size;
+      iov_copy[i_cp].iov_len = (MHD_iov_size_) element_size;
       i_cp++;
     }
     mhd_assert (num_copy_elements == i_cp);