From c8b64bd02324ec48d73c7e01982f06c0218b0f87 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 6 Aug 2025 15:48:10 -0700 Subject: [PATCH] quic: fixup NO_ERROR macro conflict on windows PR-URL: https://github.com/nodejs/node/pull/59381 Fixes: https://github.com/nodejs/node/issues/59369 Reviewed-By: Filip Skokan Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau --- src/quic/data.cc | 2 ++ src/quic/data.h | 6 +++++- test/cctest/test_quic_error.cc | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/quic/data.cc b/src/quic/data.cc index 13e756bb0c..3a0f9bcff8 100644 --- a/src/quic/data.cc +++ b/src/quic/data.cc @@ -386,6 +386,8 @@ const QuicError QuicError::FromConnectionClose(ngtcp2_conn* session) { QUIC_TRANSPORT_ERRORS(V) #undef V +const QuicError QuicError::TRANSPORT_NO_ERROR = + ForTransport(TransportError::NO_ERROR_); const QuicError QuicError::HTTP3_NO_ERROR = ForApplication(NGHTTP3_H3_NO_ERROR); const QuicError QuicError::VERSION_NEGOTIATION = ForVersionNegotiation(); const QuicError QuicError::IDLE_CLOSE = ForIdleClose(); diff --git a/src/quic/data.h b/src/quic/data.h index a63bc24b63..acd390c90c 100644 --- a/src/quic/data.h +++ b/src/quic/data.h @@ -108,7 +108,6 @@ class Store final : public MemoryRetainer { // Periodically, these need to be updated to match the latest ngtcp2 defs. #define QUIC_TRANSPORT_ERRORS(V) \ - V(NO_ERROR) \ V(INTERNAL_ERROR) \ V(CONNECTION_REFUSED) \ V(FLOW_CONTROL_ERROR) \ @@ -155,6 +154,10 @@ class QuicError final : public MemoryRetainer { public: // The known error codes for the transport namespace. enum class TransportError : error_code { + // NO_ERROR has to be treated specially since it is a macro on + // some Windows cases and results in a compile error if we leave + // it as is. + NO_ERROR_ = NGTCP2_NO_ERROR, #define V(name) name = NGTCP2_##name, QUIC_TRANSPORT_ERRORS(V) #undef V @@ -273,6 +276,7 @@ class QuicError final : public MemoryRetainer { static const QuicError FromConnectionClose(ngtcp2_conn* session); + static const QuicError TRANSPORT_NO_ERROR; #define V(name) static const QuicError TRANSPORT_##name; QUIC_TRANSPORT_ERRORS(V) #undef V diff --git a/test/cctest/test_quic_error.cc b/test/cctest/test_quic_error.cc index 04e3524ff6..b3677603c4 100644 --- a/test/cctest/test_quic_error.cc +++ b/test/cctest/test_quic_error.cc @@ -16,7 +16,7 @@ TEST(QuicError, NoError) { CHECK_EQ(err.reason(), ""); CHECK_EQ(err, QuicError::TRANSPORT_NO_ERROR); - CHECK_EQ(QuicError::TransportError::NO_ERROR, QuicError::QUIC_NO_ERROR); + CHECK_EQ(QuicError::TransportError::NO_ERROR_, QuicError::QUIC_NO_ERROR); CHECK_EQ(QuicError::Http3Error::H3_NO_ERROR, QuicError::HTTP3_NO_ERROR_CODE); QuicError err2("a reason");