commit ba5174d48808a07c442af67274c2364998caeb2b
parent 70a4aff15b995f0e7c99a9935bef0a24362614eb
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Fri, 23 Apr 2021 13:51:35 +0300
Fixed build with MSVC, fixed compiler warnings
Diffstat:
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/microhttpd/internal.h b/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
diff --git a/src/microhttpd/mhd_send.c b/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;
}
}
diff --git a/src/microhttpd/response.c b/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);