From ddc19f7f92ff0aaa5ba17ff5e5fab9c82e8339fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 1 Feb 2023 21:58:18 +0000 Subject: [PATCH] Suppress clang warning for musl libc inline Closes https://github.com/dart-lang/sdk/pull/51191 GitOrigin-RevId: d7064c43adce0b115c79e818800e44ba4f60739e Change-Id: Ie73e96c83294d43baf3be6772cb84705ba2d2712 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280136 Reviewed-by: Slava Egorov Commit-Queue: Slava Egorov --- build/config/compiler/BUILD.gn | 5 +---- runtime/bin/socket_base_posix.cc | 13 ++++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index feb13b1af62..b9a16b3c924 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -672,12 +672,9 @@ config("chromium_code") { cflags = [ "-Wall", "-Wextra", + "-Werror", ] - if (dart_sysroot != "alpine") { - cflags += [ "-Werror" ] - } - defines = [] if (!using_sanitizer && !is_clang) { # _FORTIFY_SOURCE isn't really supported by Clang now, see diff --git a/runtime/bin/socket_base_posix.cc b/runtime/bin/socket_base_posix.cc index caa7ab87492..e29104a1132 100644 --- a/runtime/bin/socket_base_posix.cc +++ b/runtime/bin/socket_base_posix.cc @@ -21,6 +21,13 @@ #include "bin/socket_base_macos.h" #include "platform/signal_blocker.h" +// We wrap CMSG_NXTHDR to suppress sign-compare warnings which occur on musl. +#define CMSG_NEXTHDR(mhdr, cmsg) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wsign-compare\"") \ + CMSG_NXTHDR(mhdr, cmsg) \ + _Pragma("clang diagnostic pop") + namespace dart { namespace bin { @@ -151,13 +158,13 @@ intptr_t SocketBase::ReceiveMessage(intptr_t fd, size_t num_messages = 0; while (cmsg != nullptr) { num_messages++; - cmsg = CMSG_NXTHDR(&msg, cmsg); + cmsg = CMSG_NEXTHDR(&msg, cmsg); } (*p_messages) = reinterpret_cast( Dart_ScopeAllocate(sizeof(SocketControlMessage) * num_messages)); SocketControlMessage* control_message = *p_messages; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; - cmsg = CMSG_NXTHDR(&msg, cmsg), control_message++) { + cmsg = CMSG_NEXTHDR(&msg, cmsg), control_message++) { void* data = CMSG_DATA(cmsg); size_t data_length = cmsg->cmsg_len - (reinterpret_cast(data) - reinterpret_cast(cmsg)); @@ -260,7 +267,7 @@ intptr_t SocketBase::SendMessage(intptr_t fd, struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg); message = messages; for (intptr_t i = 0; i < num_messages; - i++, message++, cmsg = CMSG_NXTHDR(&msg, cmsg)) { + i++, message++, cmsg = CMSG_NEXTHDR(&msg, cmsg)) { ASSERT(message->is_file_descriptors_control_message()); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS;