[compiler-rt] [sanitizer_common] Suppress warning of cast from SignalHandlerType to sa_sigaction_t (PR #86046)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 16:54:04 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Thurston Dang (thurstond)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/86046.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp (+1-1)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/86046
More information about the llvm-commits
mailing list