commit 422192c53c00370db1fe5f996d1cf6fdadc161a7
parent ad9233a867709195fe1450329b52d2bf1732e935
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Thu, 24 Apr 2025 19:21:09 +0200
Muted "marked as unused, but used" warning with OpenSSL
Diffstat:
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -546,6 +546,12 @@ AS_CASE([${enable_build_type}],[release|release-*],
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
+CFLAGS="${user_CFLAGS}"
+MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac],
+ [
+ AC_DEFINE([[HAVE_WUSED_BUT_MARKED_UNUSED]],[[1]],[Define to '1' i][f -Wused-but-marked-unused flag is supported by compiler])
+ ]
+)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
# Additional flags are checked and added at the end of 'configure'
diff --git a/src/mhd2/tls_open_funcs.c b/src/mhd2/tls_open_funcs.c
@@ -56,6 +56,15 @@
#include "mhd_public_api.h"
+#if defined(HAVE_WUSED_BUT_MARKED_UNUSED) && defined(__GNUC__)
+# define mhd_NOWARN_USED_UNUSED \
+ MHD_WARN_PUSH_ MHD_WARN_IGNORE_ ("-Wused-but-marked-unused")
+# define mhd_RESTORE_WARN_USED_UNUSED MHD_WARN_POP_
+#else
+# define mhd_NOWARN_USED_UNUSED /* empty */
+# define mhd_RESTORE_WARN_USED_UNUSED /* empty */
+#endif
+
#ifdef mhd_USE_TLS_DEBUG_MESSAGES
static MHD_FN_PAR_NONNULL_ (1) int
@@ -231,6 +240,8 @@ daemon_init_lib_ctx (struct MHD_Daemon *restrict d,
mhd_DBG_PRINT_TLS_ERRS ();
libctx_inited = true; /* Nothing to initialise */
+ mhd_NOWARN_USED_UNUSED
+
if ((ERR_LIB_CONF != ERR_GET_LIB (err)) ||
(CONF_R_NO_SUCH_FILE != ERR_GET_REASON (err)))
{
@@ -240,6 +251,8 @@ daemon_init_lib_ctx (struct MHD_Daemon *restrict d,
"file '%s'"), \
conf_filename);
}
+
+ mhd_RESTORE_WARN_USED_UNUSED
}
else /* NCONF_load() succeed */
{
@@ -590,6 +603,9 @@ daemon_load_certs_chain_obio (struct MHD_Daemon *restrict d,
{
unsigned long err;
err = ERR_peek_last_error ();
+
+ mhd_NOWARN_USED_UNUSED
+
if ((ERR_LIB_PEM == ERR_GET_LIB (err)) &&
(PEM_R_NO_START_LINE == ERR_GET_REASON (err)))
{
@@ -600,7 +616,11 @@ daemon_load_certs_chain_obio (struct MHD_Daemon *restrict d,
mhd_assert (MHD_SC_OK == ret);
return MHD_SC_OK; /* Success exit point */
}
+
+ mhd_RESTORE_WARN_USED_UNUSED
+
mhd_DBG_PRINT_TLS_ERRS ();
+
mhd_LOG_MSG (d, MHD_SC_TLS_DAEMON_INIT_FAILED, \
"Failed to load next object in the certificates " \
"chain");