Fix MacOS build issues. PiperOrigin-RevId: 927452229
diff --git a/centipede/runner_dl_info.cc b/centipede/runner_dl_info.cc index 6d06a1b..95e2286 100644 --- a/centipede/runner_dl_info.cc +++ b/centipede/runner_dl_info.cc
@@ -30,6 +30,7 @@ #include <cstring> #ifdef __APPLE__ +#include <algorithm> #include <functional> #endif // __APPLE__
diff --git a/centipede/runner_fork_server.cc b/centipede/runner_fork_server.cc index afd7bc2..6f67717 100644 --- a/centipede/runner_fork_server.cc +++ b/centipede/runner_fork_server.cc
@@ -212,37 +212,40 @@ struct sigaction sigusr1_act{}; sigusr1_act.sa_handler = [](int) {}; + // On MacOS, sigaddset() and sigemptyset() will always return 0 and cause + // clang to complain about unreachable code unless 0 is surrounded with extra + // parentheses to indicate it is "dead" code. sigset_t server_sigset; if (sigprocmask(SIG_SETMASK, nullptr, &server_sigset) != 0) { Exit("###sigprocmask() failed to get the existing sigset\n"); } - if (sigaddset(&server_sigset, SIGINT) != 0) { + if (sigaddset(&server_sigset, SIGINT) != (0)) { Exit("###sigaddset() failed to add SIGINT\n"); } - if (sigaddset(&server_sigset, SIGTERM) != 0) { + if (sigaddset(&server_sigset, SIGTERM) != (0)) { Exit("###sigaddset() failed to add SIGTERM\n"); } - if (sigaddset(&server_sigset, SIGCHLD) != 0) { + if (sigaddset(&server_sigset, SIGCHLD) != (0)) { Exit("###sigaddset() failed to add SIGCHLD\n"); } - if (sigaddset(&server_sigset, SIGUSR1) != 0) { + if (sigaddset(&server_sigset, SIGUSR1) != (0)) { Exit("###sigaddset() failed to add SIGUSR1\n"); } sigset_t wait_sigset; - if (sigemptyset(&wait_sigset) != 0) { + if (sigemptyset(&wait_sigset) != (0)) { Exit("###sigemptyset() failed\n"); } - if (sigaddset(&wait_sigset, SIGINT) != 0) { + if (sigaddset(&wait_sigset, SIGINT) != (0)) { Exit("###sigaddset() failed to add SIGINT to the wait sigset\n"); } - if (sigaddset(&wait_sigset, SIGTERM) != 0) { + if (sigaddset(&wait_sigset, SIGTERM) != (0)) { Exit("###sigaddset() failed to add SIGTERM to the wait sigset\n"); } - if (sigaddset(&wait_sigset, SIGCHLD) != 0) { + if (sigaddset(&wait_sigset, SIGCHLD) != (0)) { Exit("###sigaddset() failed to add SIGCHLD to the wait sigset\n"); } - if (sigaddset(&wait_sigset, SIGUSR1) != 0) { + if (sigaddset(&wait_sigset, SIGUSR1) != (0)) { Exit("###sigaddset() failed to add SIGUSR1 to the wait sigset\n"); }
diff --git a/fuzztest/internal/centipede_adaptor.cc b/fuzztest/internal/centipede_adaptor.cc index c507eb2..bc505a6 100644 --- a/fuzztest/internal/centipede_adaptor.cc +++ b/fuzztest/internal/centipede_adaptor.cc
@@ -135,7 +135,7 @@ start_pos - current_argv_pos); ++start_pos; } - return result; + return results; #elif defined(__linux__) const int fd = open("/proc/self/cmdline", O_RDONLY); if (fd < 0) {