mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-27 04:09:31 +03:00
GNU/Linux fixes
This commit is contained in:
+10
-10
@@ -279,7 +279,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
union mhd_SockaddrAny sa_all;
|
||||
const struct sockaddr *p_use_sa;
|
||||
socklen_t use_sa_size;
|
||||
uint_fast16_t sk_port;
|
||||
uint_least16_t sk_port;
|
||||
bool is_non_block;
|
||||
bool is_non_inhr;
|
||||
enum MHD_StatusCode ret;
|
||||
@@ -351,7 +351,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
return MHD_SC_CONFIGURATION_WRONG_SA_SIZE;
|
||||
}
|
||||
memcpy (&(sa_all.sa_i4), s->bind_sa.v_sa, sizeof(sa_all.sa_i4));
|
||||
sk_port = (uint_fast16_t) ntohs (sa_all.sa_i4.sin_port);
|
||||
sk_port = (uint_least16_t) ntohs (sa_all.sa_i4.sin_port);
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
||||
sa_all.sa_i4.sin_len = (socklen_t) sizeof(sa_all.sa_i4);
|
||||
#endif
|
||||
@@ -369,7 +369,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
return MHD_SC_CONFIGURATION_WRONG_SA_SIZE;
|
||||
}
|
||||
memcpy (&(sa_all.sa_i6), s->bind_sa.v_sa, s->bind_sa.v_sa_len);
|
||||
sk_port = (uint_fast16_t) ntohs (sa_all.sa_i6.sin6_port);
|
||||
sk_port = (uint_least16_t) ntohs (sa_all.sa_i6.sin6_port);
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
|
||||
sa_all.sa_i6.sin6_len = (socklen_t) s->bind_sa.v_sa_len;
|
||||
#endif
|
||||
@@ -1019,12 +1019,12 @@ detect_listen_type_and_port (struct MHD_Daemon *restrict d)
|
||||
{
|
||||
case AF_INET:
|
||||
d->net.listen.type = mhd_SOCKET_TYPE_IP;
|
||||
d->net.listen.port = (uint_fast16_t) ntohs (sa_all.sa_i4.sin_port);
|
||||
d->net.listen.port = (uint_least16_t) ntohs (sa_all.sa_i4.sin_port);
|
||||
break;
|
||||
#ifdef HAVE_INET6
|
||||
case AF_INET6:
|
||||
d->net.listen.type = mhd_SOCKET_TYPE_IP;
|
||||
d->net.listen.port = (uint_fast16_t) ntohs (sa_all.sa_i6.sin6_port);
|
||||
d->net.listen.port = (uint_least16_t) ntohs (sa_all.sa_i6.sin6_port);
|
||||
break;
|
||||
#endif /* HAVE_INET6 */
|
||||
#ifdef MHD_AF_UNIX
|
||||
@@ -1068,7 +1068,7 @@ init_epoll (struct MHD_Daemon *restrict d)
|
||||
mhd_assert ((mhd_POLL_TYPE_EPOLL != d->events.poll_type) || \
|
||||
(MHD_INVALID_SOCKET == d->events.data.epoll.e_fd));
|
||||
#ifdef HAVE_EPOLL_CREATE1
|
||||
e_fd = epoll_create1 (FD_CLOEXEC);
|
||||
e_fd = epoll_create1 (EFD_CLOEXEC);
|
||||
#else /* ! HAVE_EPOLL_CREATE1 */
|
||||
e_fd = epoll_create (128); /* The number is usually ignored */
|
||||
if (0 <= e_fd)
|
||||
@@ -1573,7 +1573,7 @@ allocate_events (struct MHD_Daemon *restrict d)
|
||||
#ifdef MHD_USE_THREADS
|
||||
++num_elements; /* For ITC */
|
||||
#endif
|
||||
if (MHD_INVALID_SOCKET != d->net.listen)
|
||||
if (MHD_INVALID_SOCKET != d->net.listen.fd)
|
||||
++num_elements;
|
||||
|
||||
/* Trade neglectable performance penalty for memory saving */
|
||||
@@ -1723,7 +1723,7 @@ deinit_itc (struct MHD_Daemon *restrict d)
|
||||
#ifdef MHD_USE_THREADS
|
||||
// TODO: add and process "thread unsafe" daemon's option
|
||||
mhd_assert (! mhd_ITC_IS_INVALID (d->threading.itc));
|
||||
mhd_itc_destroy (d->threading.itc);
|
||||
(void) mhd_itc_destroy (d->threading.itc);
|
||||
#endif /* MHD_USE_THREADS */
|
||||
}
|
||||
|
||||
@@ -1801,7 +1801,7 @@ add_itc_and_listen_to_monitoring (struct MHD_Daemon *restrict d)
|
||||
reg_event.events = EPOLLIN;
|
||||
reg_event.data.u64 = (uint64_t) mhd_SOCKET_REL_MARKER_ITC; /* uint64_t is used in the epoll header */
|
||||
if (0 != epoll_ctl (d->events.data.epoll.e_fd, EPOLL_CTL_ADD,
|
||||
mhd_itc_r_fd (d->threading.itc), reg_event))
|
||||
mhd_itc_r_fd (d->threading.itc), ®_event))
|
||||
{
|
||||
MHD_LOG_MSG (d, MHD_SC_EPOLL_ADD_DAEMON_FDS_FAILURE, \
|
||||
"Failed to add ITC fd to the epoll monitoring.");
|
||||
@@ -2003,7 +2003,7 @@ set_connections_total_limits (struct MHD_Daemon *restrict d,
|
||||
#ifdef MHD_POSIX_SOCKETS
|
||||
if (1)
|
||||
{
|
||||
limit_by_num = d->net.cfg.max_fd_num;
|
||||
limit_by_num = (unsigned int) d->net.cfg.max_fd_num;
|
||||
if (0 != limit_by_num)
|
||||
{
|
||||
/* Find the upper limit.
|
||||
|
||||
@@ -468,7 +468,7 @@ struct mhd_ListenSocket
|
||||
*
|
||||
* Zero if unknown and for non-IP socket.
|
||||
*/
|
||||
uint_fast16_t port;
|
||||
uint_least16_t port;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+9
-6
@@ -121,11 +121,11 @@ freebsd_sendfile_init_ (void)
|
||||
else
|
||||
{
|
||||
freebsd_sendfile_flags_ =
|
||||
SF_FLAGS ((uint_fast16_t) \
|
||||
SF_FLAGS ((uint_least16_t) \
|
||||
((mhd_SENFILE_CHUNK_SIZE + sys_page_size - 1) / sys_page_size) \
|
||||
& 0xFFFFU, SF_NODISKIO);
|
||||
freebsd_sendfile_flags_thd_p_c_ =
|
||||
SF_FLAGS ((uint_fast16_t) \
|
||||
SF_FLAGS ((uint_least16_t) \
|
||||
((mhd_SENFILE_CHUNK_SIZE_FOR_THR_P_C + sys_page_size - 1) \
|
||||
/ sys_page_size) & 0xFFFFU, SF_NODISKIO);
|
||||
}
|
||||
@@ -771,8 +771,8 @@ mhd_plain_send (struct MHD_Connection *restrict c,
|
||||
pre_send_setopt (c, true, push_data);
|
||||
#ifdef mhd_USE_MSG_MORE
|
||||
res = mhd_sys_send4 (c->socket_fd,
|
||||
buffer,
|
||||
buffer_size,
|
||||
buf,
|
||||
buf_size,
|
||||
push_data ? 0 : MSG_MORE);
|
||||
#else
|
||||
res = mhd_sys_send4 (c->socket_fd,
|
||||
@@ -1105,7 +1105,7 @@ MHD_FN_PAR_OUT_ (2) enum mhd_SocketError
|
||||
mhd_send_sendfile (struct MHD_Connection *restrict connection,
|
||||
size_t *restrict sent)
|
||||
{
|
||||
#ifdef 0
|
||||
#if 0
|
||||
ssize_t ret;
|
||||
const int file_fd = connection->rp.response->fd;
|
||||
uint64_t left;
|
||||
@@ -1343,6 +1343,9 @@ send_iov_nontls (struct MHD_Connection *restrict connection,
|
||||
{
|
||||
bool send_error;
|
||||
size_t items_to_send;
|
||||
#ifndef MSG_NOSIGNAL_OR_ZERO
|
||||
ssize_t res;
|
||||
#endif
|
||||
#ifdef HAVE_SENDMSG
|
||||
struct msghdr msg;
|
||||
#elif defined(MHD_WINSOCK_SOCKETS)
|
||||
@@ -1379,7 +1382,7 @@ send_iov_nontls (struct MHD_Connection *restrict connection,
|
||||
|
||||
pre_send_setopt (connection, true, push_data);
|
||||
res = sendmsg (connection->socket_fd, &msg,
|
||||
MSG_NOSIGNAL_OR_ZERO | (push_data ? 0 : mhd_MSG_MORE));
|
||||
mhd_MSG_NOSIGNAL | (push_data ? 0 : mhd_MSG_MORE));
|
||||
if (0 < res)
|
||||
*sent = (size_t) res;
|
||||
else
|
||||
|
||||
+37
-37
@@ -512,8 +512,8 @@ toxdigitvalue (char c)
|
||||
#else /* MHD_FAVOR_SMALL_CODE */
|
||||
if (c <= 9)
|
||||
{
|
||||
if (c >= 0)
|
||||
return (unsigned char) (c - '0');
|
||||
if (c >= 0)
|
||||
return (unsigned char) (c - '0');
|
||||
}
|
||||
else if (c <= 'F')
|
||||
{
|
||||
@@ -680,7 +680,7 @@ charsequalcaseless (const char c1, const char c2)
|
||||
#ifndef MHD_FAVOR_SMALL_CODE
|
||||
MHD_INTERNAL bool
|
||||
mhd_str_equal_caseless (const char *str1,
|
||||
const char *str2)
|
||||
const char *str2)
|
||||
{
|
||||
while (0 != (*str1))
|
||||
{
|
||||
@@ -703,8 +703,8 @@ mhd_str_equal_caseless (const char *str1,
|
||||
|
||||
MHD_INTERNAL bool
|
||||
mhd_str_equal_caseless_n (const char *const str1,
|
||||
const char *const str2,
|
||||
size_t maxlen)
|
||||
const char *const str2,
|
||||
size_t maxlen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -745,8 +745,8 @@ mhd_str_equal_caseless_bin_n (const char *const str1,
|
||||
|
||||
MHD_INTERNAL bool
|
||||
mhd_str_has_token_caseless (const char *str,
|
||||
const char *const token,
|
||||
size_t token_len)
|
||||
const char *const token,
|
||||
size_t token_len)
|
||||
{
|
||||
if (0 == token_len)
|
||||
return false;
|
||||
@@ -1097,7 +1097,7 @@ mhd_str_remove_tokens_caseless (char *restrict str,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_to_uint64 (const char *restrict str,
|
||||
uint_fast64_t *restrict out_val)
|
||||
uint_fast64_t *restrict out_val)
|
||||
{
|
||||
const char *const start = str;
|
||||
uint_fast64_t res;
|
||||
@@ -1128,8 +1128,8 @@ mhd_str_to_uint64 (const char *restrict str,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_to_uint64_n (const char *restrict str,
|
||||
size_t maxlen,
|
||||
uint_fast64_t *restrict out_val)
|
||||
size_t maxlen,
|
||||
uint_fast64_t *restrict out_val)
|
||||
{
|
||||
uint_fast64_t res;
|
||||
size_t i;
|
||||
@@ -1161,7 +1161,7 @@ mhd_str_to_uint64_n (const char *restrict str,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_strx_to_uint32 (const char *restrict str,
|
||||
uint_fast32_t *restrict out_val)
|
||||
uint_fast32_t *restrict out_val)
|
||||
{
|
||||
const char *const start = str;
|
||||
uint_fast32_t res;
|
||||
@@ -1195,8 +1195,8 @@ mhd_strx_to_uint32 (const char *restrict str,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_strx_to_uint32_n (const char *restrict str,
|
||||
size_t maxlen,
|
||||
uint_fast32_t *restrict out_val)
|
||||
size_t maxlen,
|
||||
uint_fast32_t *restrict out_val)
|
||||
{
|
||||
size_t i;
|
||||
uint_fast32_t res;
|
||||
@@ -1240,7 +1240,7 @@ mhd_strx_to_uint32_n (const char *restrict str,
|
||||
*/
|
||||
MHD_INTERNAL size_t
|
||||
mhd_strx_to_uint64 (const char *restrict str,
|
||||
uint_fast64_t *restrict out_val)
|
||||
uint_fast64_t *restrict out_val)
|
||||
{
|
||||
const char *const start = str;
|
||||
uint_fast64_t res;
|
||||
@@ -1286,8 +1286,8 @@ mhd_strx_to_uint64 (const char *restrict str,
|
||||
*/
|
||||
MHD_INTERNAL size_t
|
||||
mhd_strx_to_uint64_n (const char *restrict str,
|
||||
size_t maxlen,
|
||||
uint_fast64_t *restrict out_val)
|
||||
size_t maxlen,
|
||||
uint_fast64_t *restrict out_val)
|
||||
{
|
||||
size_t i;
|
||||
uint_fast64_t res;
|
||||
@@ -1337,11 +1337,11 @@ mhd_strx_to_uint64_n (const char *restrict str,
|
||||
*/
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_to_uvalue_n (const char *restrict str,
|
||||
size_t maxlen,
|
||||
void *restrict out_val,
|
||||
size_t val_size,
|
||||
uint_fast64_t max_val,
|
||||
unsigned int base)
|
||||
size_t maxlen,
|
||||
void *restrict out_val,
|
||||
size_t val_size,
|
||||
uint_fast64_t max_val,
|
||||
unsigned int base)
|
||||
{
|
||||
size_t i;
|
||||
uint_fast64_t res;
|
||||
@@ -1422,13 +1422,13 @@ mhd_uint32_to_strx (uint_fast32_t val,
|
||||
|
||||
#ifndef MHD_FAVOR_SMALL_CODE
|
||||
MHD_INTERNAL size_t
|
||||
mhd_uint16_to_str (uint_fast16_t val,
|
||||
mhd_uint16_to_str (uint_least16_t val,
|
||||
char *buf,
|
||||
size_t buf_size)
|
||||
{
|
||||
char *chr; /**< pointer to the current printed digit */
|
||||
/* The biggest printable number is 65535 */
|
||||
uint_fast16_t divisor = UINT16_C (10000);
|
||||
uint_least16_t divisor = UINT16_C (10000);
|
||||
int digit;
|
||||
|
||||
chr = buf;
|
||||
@@ -1450,7 +1450,7 @@ mhd_uint16_to_str (uint_fast16_t val,
|
||||
buf_size--;
|
||||
if (1 == divisor)
|
||||
return (size_t) (chr - buf);
|
||||
val = (uint_fast16_t) (val % divisor);
|
||||
val = (uint_least16_t) (val % divisor);
|
||||
divisor /= 10;
|
||||
digit = (int) (val / divisor);
|
||||
mhd_assert (digit < 10);
|
||||
@@ -1599,7 +1599,7 @@ mhd_hex_to_bin (const char *restrict hex,
|
||||
const int l = toxdigitvalue (hex[r++]);
|
||||
if (0 > l)
|
||||
return 0;
|
||||
((uint8_t *)bin)[w++] = (uint8_t) ((unsigned int) l);
|
||||
((uint8_t *) bin)[w++] = (uint8_t) ((unsigned int) l);
|
||||
}
|
||||
while (r < len)
|
||||
{
|
||||
@@ -1607,9 +1607,9 @@ mhd_hex_to_bin (const char *restrict hex,
|
||||
const int l = toxdigitvalue (hex[r++]);
|
||||
if ((0 > h) || (0 > l))
|
||||
return 0;
|
||||
((uint8_t *)bin)[w++] = (uint8_t) ( ((uint8_t) (((uint8_t)
|
||||
((unsigned int) h)) << 4))
|
||||
| ((uint8_t) ((unsigned int) l)) );
|
||||
((uint8_t *) bin)[w++] = (uint8_t) ( ((uint8_t) (((uint8_t)
|
||||
((unsigned int) h)) << 4))
|
||||
| ((uint8_t) ((unsigned int) l)) );
|
||||
}
|
||||
mhd_assert (len == r);
|
||||
mhd_assert ((len + 1) / 2 == w);
|
||||
@@ -1619,16 +1619,16 @@ mhd_hex_to_bin (const char *restrict hex,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_pct_decode_strict_n (const char *pct_encoded,
|
||||
size_t pct_encoded_len,
|
||||
char *decoded,
|
||||
size_t buf_size)
|
||||
size_t pct_encoded_len,
|
||||
char *decoded,
|
||||
size_t buf_size)
|
||||
{
|
||||
#ifdef MHD_FAVOR_SMALL_CODE
|
||||
bool broken;
|
||||
size_t res;
|
||||
|
||||
res = mhd_str_pct_decode_lenient_n (pct_encoded, pct_encoded_len, decoded,
|
||||
buf_size, &broken);
|
||||
buf_size, &broken);
|
||||
if (broken)
|
||||
return 0;
|
||||
return res;
|
||||
@@ -1702,10 +1702,10 @@ mhd_str_pct_decode_strict_n (const char *pct_encoded,
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_pct_decode_lenient_n (const char *pct_encoded,
|
||||
size_t pct_encoded_len,
|
||||
char *decoded,
|
||||
size_t buf_size,
|
||||
bool *broken_encoding)
|
||||
size_t pct_encoded_len,
|
||||
char *decoded,
|
||||
size_t buf_size,
|
||||
bool *broken_encoding)
|
||||
{
|
||||
size_t r;
|
||||
size_t w;
|
||||
@@ -1857,7 +1857,7 @@ mhd_str_pct_decode_in_place_strict (char *str)
|
||||
|
||||
MHD_INTERNAL size_t
|
||||
mhd_str_pct_decode_in_place_lenient (char *str,
|
||||
bool *broken_encoding)
|
||||
bool *broken_encoding)
|
||||
{
|
||||
#ifdef MHD_FAVOR_SMALL_CODE
|
||||
size_t len;
|
||||
|
||||
+3
-3
@@ -397,7 +397,7 @@ mhd_uint32_to_strx (uint_fast32_t val,
|
||||
|
||||
#ifndef MHD_FAVOR_SMALL_CODE
|
||||
/**
|
||||
* Convert uint_fast16_t value to decimal US-ASCII string.
|
||||
* Convert uint_least16_t value to decimal US-ASCII string.
|
||||
* @note: result is NOT zero-terminated.
|
||||
* @param val the value to convert
|
||||
* @param buf the buffer to result to
|
||||
@@ -406,7 +406,7 @@ mhd_uint32_to_strx (uint_fast32_t val,
|
||||
* zero if buffer is too small (buffer may be modified).
|
||||
*/
|
||||
MHD_INTERNAL size_t
|
||||
mhd_uint16_to_str (uint_fast16_t val,
|
||||
mhd_uint16_to_str (uint_least16_t val,
|
||||
char *buf,
|
||||
size_t buf_size);
|
||||
|
||||
@@ -431,7 +431,7 @@ mhd_uint64_to_str (uint_fast64_t val,
|
||||
|
||||
|
||||
/**
|
||||
* Convert uint_fast16_t value to decimal US-ASCII string padded with
|
||||
* Convert uint_least16_t value to decimal US-ASCII string padded with
|
||||
* zeros on the left side.
|
||||
*
|
||||
* @note: result is NOT zero-terminated.
|
||||
|
||||
Reference in New Issue
Block a user