commit 13e217f5c2e5647552e4452406a43c8dc0782a35
parent 6933158a95542a9aa1fb3862d3bd93cc71440ca3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Wed, 28 Sep 2022 10:46:20 +0300
Added workarounds for clang with W32 and MinGW incorrect headers
Diffstat:
2 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -325,7 +325,7 @@ AS_CASE([${enable_build_type}],[debug|debugger],
MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG_IFELSE(
[
- # clang produce warning when string pointer is used as a formar for v*printf() function
+ # clang produce warning when string pointer is used as a format specifier for v*printf() function
AS_VAR_IF([mhd_cv_cc_clang_based],["yes"],[MHD_CHECK_ADD_CC_CFLAG([-Wno-format-nonliteral], [CFLAGS_ac])])
],[],
[CFLAGS_ac], [-Wformat=2], [-Wformat]
@@ -359,7 +359,39 @@ AS_CASE([${enable_build_type}],[debug|debugger],
MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-noreturn -Wmissing-variable-declarations -Wnested-anon-types], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wnewline-eof -Wover-aligned -Wredundant-parens], [CFLAGS_ac])
MHD_CHECK_ADD_CC_CFLAGS([-Wshift-sign-overflow -Wtautological-compare -Wunaligned-access], [CFLAGS_ac])
- MHD_CHECK_ADD_CC_CFLAGS([-Wunused -Wused-but-marked-unused -Wzero-as-null-pointer-constant -Wzero-length-array], [CFLAGS_ac])
+ MHD_CHECK_ADD_CC_CFLAGS([-Wunused -Wzero-as-null-pointer-constant -Wzero-length-array], [CFLAGS_ac])
+ MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac],
+ [
+ AC_CACHE_CHECK([whether $[]CC -Wused-but-marked-unused works with system headers],
+ [mhd_cv_wused_but_marked_unused_sys_header],
+ [
+ SAVE_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag="yes"
+ CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${user_CFLAGS}"
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_SOURCE([[
+#include <stdio.h>
+
+int main(void)
+{
+ char buf[16];
+ return (int) snprintf(buf, 16, "test");
+}
+ ]]
+ )
+ ],
+ [mhd_cv_wused_but_marked_unused_sys_header="yes"],
+ [mhd_cv_wused_but_marked_unused_sys_header="no"]
+ )
+ ac_c_werror_flag="$SAVE_ac_c_werror_flag"
+ ]
+ )
+ AS_VAR_IF([mhd_cv_wused_but_marked_unused_sys_header],["yes"],
+ [MHD_APPEND_FLAG_TO_VAR([CFLAGS_ac],[-Wused-but-marked-unused])]
+ )
+ ]
+ )
#
# Removed flags:
#
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -815,20 +815,20 @@ urh_from_fdset (struct MHD_UpgradeResponseHandle *urh,
if (MHD_INVALID_SOCKET != conn_sckt)
{
- if (FD_ISSET (conn_sckt, rs))
+ if (FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (rs)))
urh->app.celi |= MHD_EPOLL_STATE_READ_READY;
- if (FD_ISSET (conn_sckt, ws))
+ if (FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (ws)))
urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY;
- if (FD_ISSET (conn_sckt, es))
+ if (FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (es)))
urh->app.celi |= MHD_EPOLL_STATE_ERROR;
}
if ((MHD_INVALID_SOCKET != mhd_sckt))
{
- if (FD_ISSET (mhd_sckt, rs))
+ if (FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (rs)))
urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY;
- if (FD_ISSET (mhd_sckt, ws))
+ if (FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (ws)))
urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY;
- if (FD_ISSET (mhd_sckt, es))
+ if (FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (es)))
urh->mhd.celi |= MHD_EPOLL_STATE_ERROR;
}
}
@@ -4299,7 +4299,7 @@ internal_run_from_select (struct MHD_Daemon *daemon,
will trigger select again and will be processed */
if ( (MHD_ITC_IS_VALID_ (daemon->itc)) &&
(FD_ISSET (MHD_itc_r_fd_ (daemon->itc),
- read_fd_set)) )
+ (fd_set *) _MHD_DROP_CONST (read_fd_set))) )
MHD_itc_clear_ (daemon->itc);
/* Process externally added connection if any */
@@ -4310,7 +4310,7 @@ internal_run_from_select (struct MHD_Daemon *daemon,
if ( (MHD_INVALID_SOCKET != (ds = daemon->listen_fd)) &&
(! daemon->was_quiesced) &&
(FD_ISSET (ds,
- read_fd_set)) )
+ (fd_set *) _MHD_DROP_CONST (read_fd_set))) )
(void) MHD_accept_connection (daemon);
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
@@ -4325,11 +4325,11 @@ internal_run_from_select (struct MHD_Daemon *daemon,
continue;
call_handlers (pos,
FD_ISSET (ds,
- read_fd_set),
+ (fd_set *) _MHD_DROP_CONST (read_fd_set)),
FD_ISSET (ds,
- write_fd_set),
+ (fd_set *) _MHD_DROP_CONST (write_fd_set)),
FD_ISSET (ds,
- except_fd_set));
+ (fd_set *) _MHD_DROP_CONST (except_fd_set)));
}
}