From 9d79589e7c8b728a592a4b6b3dee53ac471d7946 Mon Sep 17 00:00:00 2001 From: Thurston Dang Date: Wed, 20 Mar 2024 23:52:02 +0000 Subject: [PATCH] [sanitizer_common] Suppress warning of cast from SignalHandlerType to sa_sigaction_t Some buildbots have recently started complaining about "cast from 'SignalHandlerType' (aka 'void (*)(int, void *, void *)') to 'sa_sigaction_t' (aka 'void (*)(int, siginfo_t *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]" 219 | sigact.sa_sigaction = (sa_sigaction_t)handler; This patch does an intermediate cast to '(void (*) (void))' to suppress the warning. N.B. SignalHandlerType has 'void*' instead of 'siginfo_t*' because it is typedef'ed in sanitizer_common/sanitizer_common.h, which does not have access to the header (signal.h) that defines siginfo_t; we therefore cannot fix SignalHandlerType. --- compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index ece2d7d63dd619..48daa2ed25c144 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -216,7 +216,7 @@ static void MaybeInstallSigaction(int signum, struct sigaction sigact; internal_memset(&sigact, 0, sizeof(sigact)); - sigact.sa_sigaction = (sa_sigaction_t)handler; + sigact.sa_sigaction = (sa_sigaction_t)(void (*)(void))handler; // Do not block the signal from being received in that signal's handler. // Clients are responsible for handling this correctly. sigact.sa_flags = SA_SIGINFO | SA_NODEFER;