Skip to content

Commit

Permalink
clients/upsclient.c, server/netssl.c, m4/ax_c_pragmas.m4: hush -Wcast…
Browse files Browse the repository at this point in the history
…-function-type-strict due to void* vs. practical pointers with NSS method pointers [#2084]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Oct 10, 2023
1 parent a55bcd3 commit ce37a62
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,10 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert)
return -1;
}

#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type-strict"
#endif
if (verifycert) {
status = SSL_AuthCertificateHook(ups->ssl,
(SSLAuthCertificate)AuthCertificate, CERT_GetDefaultCertDB());
Expand Down Expand Up @@ -938,6 +942,9 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert)
nss_error("upscli_sslinit / SSL_HandshakeCallback");
return -1;
}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT)
#pragma GCC diagnostic pop
#endif

cert = upscli_find_host_cert(ups->host);
if (cert != NULL && cert->certname != NULL) {
Expand Down
27 changes: 27 additions & 0 deletions m4/ax_c_pragmas.m4
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,33 @@ dnl ### [CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-warning"
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcast-align" (outside functions)])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcast-function-type-strict"],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[void func(void) {
#pragma GCC diagnostic ignored "-Wcast-function-type-strict"
}
]], [])],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict=yes],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcast-function-type-strict"])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcast-function-type-strict" (outside functions)],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict_besidefunc],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wcast-function-type-strict"]], [])],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict_besidefunc=yes],
[ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict_besidefunc=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cast_function_type_strict_besidefunc" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcast-function-type-strict" (outside functions)])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wstrict-prototypes"],
[ax_cv__pragma__gcc__diags_ignored_strict_prototypes],
[AC_COMPILE_IFELSE(
Expand Down
7 changes: 7 additions & 0 deletions server/netssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ void net_starttls(nut_ctype_t *client, size_t numarg, const char **arg)
return;
}

#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type-strict"
#endif
/* Note cast to SSLAuthCertificate to prevent warning due to
* bad function prototype in NSS.
*/
Expand Down Expand Up @@ -386,6 +390,9 @@ void net_starttls(nut_ctype_t *client, size_t numarg, const char **arg)
nss_error("net_starttls / SSL_ConfigSecureServer");
return;
}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_FUNCTION_TYPE_STRICT)
#pragma GCC diagnostic pop
#endif

status = SSL_ResetHandshake(client->ssl, PR_TRUE);
if (status != SECSuccess) {
Expand Down

0 comments on commit ce37a62

Please sign in to comment.