From 21e9239e2ac2f71fba02899891a1ce99a5af0c20 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 23 Mar 2026 06:50:25 -0700 Subject: [PATCH] quic: fixup linting/formatting issues Signed-off-by: James M Snell Assisted-by: Opencode/Opus 4.6 PR-URL: https://github.com/nodejs/node/pull/62387 Reviewed-By: Stephen Belanger --- src/node_blob.cc | 3 +- src/quic/application.cc | 4 +-- src/quic/application.h | 6 ++-- src/quic/bindingdata.h | 2 +- src/quic/endpoint.cc | 14 +++----- src/quic/endpoint.h | 1 - src/quic/http3.cc | 65 ++++++++++++++++-------------------- src/quic/preferredaddress.cc | 11 +++--- src/quic/session.cc | 47 ++++++++++++-------------- src/quic/sessionticket.cc | 8 ++--- src/quic/streams.cc | 23 +++++-------- src/quic/tlscontext.cc | 10 +++--- 12 files changed, 84 insertions(+), 110 deletions(-) diff --git a/src/node_blob.cc b/src/node_blob.cc index 89521a70fee..322c0a603f1 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -411,8 +411,7 @@ void Blob::Reader::Pull(const FunctionCallbackInfo& args) { std::move(next), node::bob::OPTIONS_END, nullptr, 0)); } -void Blob::Reader::SetWakeup( - const FunctionCallbackInfo& args) { +void Blob::Reader::SetWakeup(const FunctionCallbackInfo& args) { Blob::Reader* reader; ASSIGN_OR_RETURN_UNWRAP(&reader, args.This()); CHECK(args[0]->IsFunction()); diff --git a/src/quic/application.cc b/src/quic/application.cc index 3609d4ea2e6..5605be88865 100644 --- a/src/quic/application.cc +++ b/src/quic/application.cc @@ -452,7 +452,7 @@ ssize_t Session::Application::WriteVStream(PathStorage* path, if (stream_data.fin) flags |= NGTCP2_WRITE_STREAM_FLAG_FIN; return ngtcp2_conn_writev_stream(*session_, &path->path, - // TODO(@jasnell): ECN blocked on libuv + // TODO(@jasnell): ECN blocked on libuv nullptr, dest, max_packet_size, @@ -583,7 +583,6 @@ class DefaultApplication final : public Session::Application { void ResumeStream(int64_t id) override { ScheduleStream(id); } - void BlockStream(int64_t id) override { if (auto stream = session().FindStream(id)) [[likely]] { stream->EmitBlocked(); @@ -608,7 +607,6 @@ class DefaultApplication final : public Session::Application { } } - Stream::Queue stream_queue_; }; diff --git a/src/quic/application.h b/src/quic/application.h index 52e5f314518..76f81b71557 100644 --- a/src/quic/application.h +++ b/src/quic/application.h @@ -155,9 +155,9 @@ struct Session::Application::StreamData final { BaseObjectPtr stream; static_assert(sizeof(ngtcp2_vec) == sizeof(nghttp3_vec) && - alignof(ngtcp2_vec) == alignof(nghttp3_vec) && - offsetof(ngtcp2_vec, base) == offsetof(nghttp3_vec, base) && - offsetof(ngtcp2_vec, len) == offsetof(nghttp3_vec, len), + alignof(ngtcp2_vec) == alignof(nghttp3_vec) && + offsetof(ngtcp2_vec, base) == offsetof(nghttp3_vec, base) && + offsetof(ngtcp2_vec, len) == offsetof(nghttp3_vec, len), "ngtcp2_vec and nghttp3_vec must have identical layout"); inline operator nghttp3_vec*() { return reinterpret_cast(data); diff --git a/src/quic/bindingdata.h b/src/quic/bindingdata.h index 9e778eee408..462257ebb48 100644 --- a/src/quic/bindingdata.h +++ b/src/quic/bindingdata.h @@ -43,7 +43,7 @@ class Packet; V(session_datagram_status, SessionDatagramStatus) \ V(session_handshake, SessionHandshake) \ V(session_new, SessionNew) \ - V(session_new_token, SessionNewToken) \ + V(session_new_token, SessionNewToken) \ V(session_path_validation, SessionPathValidation) \ V(session_ticket, SessionTicket) \ V(session_version_negotiation, SessionVersionNegotiation) \ diff --git a/src/quic/endpoint.cc b/src/quic/endpoint.cc index 0bec4c3c4e9..1cd8165ad65 100644 --- a/src/quic/endpoint.cc +++ b/src/quic/endpoint.cc @@ -324,8 +324,7 @@ class Endpoint::UDP::Impl final : public HandleWrap { DCHECK_NOT_NULL(impl->endpoint_); auto release_buf = [&]() { - if (buf->base != nullptr) - impl->env()->release_managed_buffer(*buf); + if (buf->base != nullptr) impl->env()->release_managed_buffer(*buf); }; // Nothing to do in these cases. Specifically, if the nread @@ -343,9 +342,8 @@ class Endpoint::UDP::Impl final : public HandleWrap { return; } - impl->endpoint_->Receive( - uv_buf_init(buf->base, static_cast(nread)), - SocketAddress(addr)); + impl->endpoint_->Receive(uv_buf_init(buf->base, static_cast(nread)), + SocketAddress(addr)); } uv_udp_t handle_; @@ -999,7 +997,6 @@ void Endpoint::Destroy(CloseContext context, int status) { this, "Destroying endpoint due to \"%s\" with status %d", ctx, status); } - state_->listening = 0; close_context_ = context; @@ -1365,9 +1362,8 @@ void Endpoint::Receive(const uv_buf_t& buf, // trusted networks), we skip the Retry and allow 0-RTT to // proceed without additional validation. if (options_.validate_address) { - Debug(this, - "Sending retry to %s due to 0RTT packet", - remote_address); + Debug( + this, "Sending retry to %s due to 0RTT packet", remote_address); SendRetry(PathDescriptor{ version, dcid, diff --git a/src/quic/endpoint.h b/src/quic/endpoint.h index 7ed9fee81e4..c445069acb5 100644 --- a/src/quic/endpoint.h +++ b/src/quic/endpoint.h @@ -311,7 +311,6 @@ class Endpoint final : public AsyncWrap, public Packet::Listener { // be prevented. void CloseGracefully(); - void PacketDone(int status) override; void EmitNewSession(const BaseObjectPtr& session); diff --git a/src/quic/http3.cc b/src/quic/http3.cc index 0fef92884e9..141dce1d5e2 100644 --- a/src/quic/http3.cc +++ b/src/quic/http3.cc @@ -455,8 +455,8 @@ class Http3ApplicationImpl final : public Session::Application { } void SetStreamPriority(const Stream& stream, - StreamPriority priority, - StreamPriorityFlags flags) override { + StreamPriority priority, + StreamPriorityFlags flags) override { nghttp3_pri pri; pri.inc = (flags == StreamPriorityFlags::NON_INCREMENTAL) ? 0 : 1; switch (priority) { @@ -471,8 +471,7 @@ class Http3ApplicationImpl final : public Session::Application { break; } if (session().is_server()) { - nghttp3_conn_set_server_stream_priority( - *this, stream.id(), &pri); + nghttp3_conn_set_server_stream_priority(*this, stream.id(), &pri); } // Client-side priority is set at request submission time via // nghttp3_conn_submit_request and is not typically changed @@ -536,12 +535,10 @@ class Http3ApplicationImpl final : public Session::Application { nghttp3_err_infer_quic_app_error_code(err))); return false; } - if (data->stream) - data->stream->Commit(datalen, data->fin); + if (data->stream) data->stream->Commit(datalen, data->fin); return true; } - SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(Http3ApplicationImpl) SET_SELF_SIZE(Http3ApplicationImpl) @@ -724,9 +721,7 @@ class Http3ApplicationImpl final : public Session::Application { // // This can be called multiple times with a decreasing id as the // peer progressively reduces the set of streams it will process. - Debug(&session(), - "HTTP/3 received GOAWAY (id=%" PRIi64 ")", - id); + Debug(&session(), "HTTP/3 received GOAWAY (id=%" PRIi64 ")", id); session().Close(Session::CloseMethod::GRACEFUL); } @@ -799,42 +794,38 @@ class Http3ApplicationImpl final : public Session::Application { return 0; } - size_t max_count = std::min(veccnt, - static_cast(kMaxVectorCount)); + size_t max_count = std::min(veccnt, static_cast(kMaxVectorCount)); nghttp3_ssize result = 0; - auto next = [&](int status, - const ngtcp2_vec* data, - size_t count, - bob::Done done) { - switch (status) { - case bob::Status::STATUS_BLOCK: - case bob::Status::STATUS_WAIT: - result = NGHTTP3_ERR_WOULDBLOCK; - return; - case bob::Status::STATUS_EOS: - *pflags |= NGHTTP3_DATA_FLAG_EOF; - break; - } - count = std::min(count, max_count); - for (size_t n = 0; n < count; n++) { - vec[n].base = data[n].base; - vec[n].len = data[n].len; - } - result = static_cast(count); - }; + auto next = + [&](int status, const ngtcp2_vec* data, size_t count, bob::Done done) { + switch (status) { + case bob::Status::STATUS_BLOCK: + case bob::Status::STATUS_WAIT: + result = NGHTTP3_ERR_WOULDBLOCK; + return; + case bob::Status::STATUS_EOS: + *pflags |= NGHTTP3_DATA_FLAG_EOF; + break; + } + count = std::min(count, max_count); + for (size_t n = 0; n < count; n++) { + vec[n].base = data[n].base; + vec[n].len = data[n].len; + } + result = static_cast(count); + }; ngtcp2_vec data[kMaxVectorCount]; stream->Pull(std::move(next), - bob::Options::OPTIONS_SYNC, - data, - max_count, - max_count); + bob::Options::OPTIONS_SYNC, + data, + max_count, + max_count); return result; } - static int on_acked_stream_data(nghttp3_conn* conn, int64_t stream_id, uint64_t datalen, diff --git a/src/quic/preferredaddress.cc b/src/quic/preferredaddress.cc index d1c5caee139..4dccbfaacd8 100644 --- a/src/quic/preferredaddress.cc +++ b/src/quic/preferredaddress.cc @@ -30,14 +30,17 @@ std::optional get_address_info( if constexpr (FAMILY == AF_INET) { if (!paddr.ipv4_present) return std::nullopt; address.port = paddr.ipv4.sin_port; - if (uv_inet_ntop(FAMILY, &paddr.ipv4.sin_addr, - address.host, sizeof(address.host)) != 0) + if (uv_inet_ntop( + FAMILY, &paddr.ipv4.sin_addr, address.host, sizeof(address.host)) != + 0) return std::nullopt; } else { if (!paddr.ipv6_present) return std::nullopt; address.port = paddr.ipv6.sin6_port; - if (uv_inet_ntop(FAMILY, &paddr.ipv6.sin6_addr, - address.host, sizeof(address.host)) != 0) + if (uv_inet_ntop(FAMILY, + &paddr.ipv6.sin6_addr, + address.host, + sizeof(address.host)) != 0) return std::nullopt; } return address; diff --git a/src/quic/session.cc b/src/quic/session.cc index ac98275cabb..449838a6d84 100644 --- a/src/quic/session.cc +++ b/src/quic/session.cc @@ -475,8 +475,7 @@ Maybe Session::Options::From(Environment* env, // Parse the optional NEW_TOKEN for address validation on reconnection. Local token_val; - if (params->Get(env->context(), state.token_string()) - .ToLocal(&token_val) && + if (params->Get(env->context(), state.token_string()).ToLocal(&token_val) && token_val->IsArrayBufferView()) { Store token_store; if (Store::From(token_val.As()).To(&token_store)) { @@ -897,9 +896,8 @@ struct Session::Impl final : public MemoryRetainer { uint64_t max_streams, void* user_data) { NGTCP2_CALLBACK_SCOPE(session) - Debug(session, - "Max remote bidi streams increased to %" PRIu64, - max_streams); + Debug( + session, "Max remote bidi streams increased to %" PRIu64, max_streams); return NGTCP2_SUCCESS; } @@ -1630,11 +1628,14 @@ bool Session::Receive(Store&& store, // ngtcp2_conn_read_pkt here, we will need to double check that the // session is not destroyed before we try doing anything with it // (like updating stats, sending pending data, etc). - int err = ngtcp2_conn_read_pkt( - *this, &path, - // TODO(@jasnell): ECN pkt_info blocked on libuv - nullptr, - vec.base, vec.len, uv_hrtime()); + int err = + ngtcp2_conn_read_pkt(*this, + &path, + // TODO(@jasnell): ECN pkt_info blocked on libuv + nullptr, + vec.base, + vec.len, + uv_hrtime()); switch (err) { case 0: { @@ -2477,10 +2478,8 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) { auto ipv4 = preferredAddress->ipv4(); if (ipv4.has_value()) { if (ipv4->host[0] == '\0' || ipv4->port == 0) return; - CHECK(SocketAddress::New(AF_INET, - ipv4->host, - ipv4->port, - &impl_->remote_address_)); + CHECK(SocketAddress::New( + AF_INET, ipv4->host, ipv4->port, &impl_->remote_address_)); preferredAddress->Use(ipv4.value()); } break; @@ -2490,10 +2489,8 @@ void Session::SelectPreferredAddress(PreferredAddress* preferredAddress) { auto ipv6 = preferredAddress->ipv6(); if (ipv6.has_value()) { if (ipv6->host[0] == '\0' || ipv6->port == 0) return; - CHECK(SocketAddress::New(AF_INET6, - ipv6->host, - ipv6->port, - &impl_->remote_address_)); + CHECK(SocketAddress::New( + AF_INET6, ipv6->host, ipv6->port, &impl_->remote_address_)); preferredAddress->Use(ipv6.value()); } break; @@ -2767,16 +2764,14 @@ void Session::EmitNewToken(const uint8_t* token, size_t len) { CallbackScope cb_scope(this); Local argv[2]; - auto buf = Buffer::Copy( - env(), reinterpret_cast(token), len); + auto buf = Buffer::Copy(env(), reinterpret_cast(token), len); if (!buf.ToLocal(&argv[0])) return; argv[1] = SocketAddressBase::Create( - env(), - std::make_shared(remote_address()))->object(); - MakeCallback( - BindingData::Get(env()).session_new_token_callback(), - arraysize(argv), - argv); + env(), std::make_shared(remote_address())) + ->object(); + MakeCallback(BindingData::Get(env()).session_new_token_callback(), + arraysize(argv), + argv); } void Session::EmitStream(const BaseObjectWeakPtr& stream) { diff --git a/src/quic/sessionticket.cc b/src/quic/sessionticket.cc index 1fce9f888fa..477d7b28399 100644 --- a/src/quic/sessionticket.cc +++ b/src/quic/sessionticket.cc @@ -1,15 +1,15 @@ #if HAVE_OPENSSL #include "guard.h" #ifndef OPENSSL_NO_QUIC -#include "sessionticket.h" -#include "tlscontext.h" -#include "session.h" -#include #include #include #include #include #include +#include +#include "session.h" +#include "sessionticket.h" +#include "tlscontext.h" namespace node { diff --git a/src/quic/streams.cc b/src/quic/streams.cc index ce8926cdced..c3d25ca10b1 100644 --- a/src/quic/streams.cc +++ b/src/quic/streams.cc @@ -83,9 +83,9 @@ namespace quic { V(ResetStream, resetStream, false) \ V(SetPriority, setPriority, false) \ V(GetPriority, getPriority, true) \ - V(GetReader, getReader, false) \ - V(InitStreamingSource, initStreamingSource, false) \ - V(Write, write, false) \ + V(GetReader, getReader, false) \ + V(InitStreamingSource, initStreamingSource, false) \ + V(Write, write, false) \ V(EndWrite, endWrite, false) // ============================================================================ @@ -149,10 +149,7 @@ namespace { // possible (e.g., SharedArrayBuffer-backed or non-detachable). // Returns nullptr on failure (error already thrown if allocation failed). std::unique_ptr CreateEntryFromBuffer( - Environment* env, - Local buffer, - size_t offset, - size_t length) { + Environment* env, Local buffer, size_t offset, size_t length) { if (length == 0) return nullptr; std::shared_ptr backing; if (buffer->IsDetachable()) { @@ -1111,8 +1108,8 @@ void Stream::set_outbound(std::shared_ptr source) { void Stream::InitStreaming() { auto env = this->env(); if (outbound_ != nullptr) { - return THROW_ERR_INVALID_STATE(env, - "Outbound data source is already initialized"); + return THROW_ERR_INVALID_STATE( + env, "Outbound data source is already initialized"); } if (!is_writable()) { return THROW_ERR_INVALID_STATE(env, "Stream is not writable"); @@ -1126,8 +1123,7 @@ void Stream::InitStreaming() { void Stream::WriteStreamData(const v8::FunctionCallbackInfo& args) { auto env = this->env(); if (outbound_ == nullptr || !outbound_->is_streaming()) { - return THROW_ERR_INVALID_STATE(env, - "Streaming source is not initialized"); + return THROW_ERR_INVALID_STATE(env, "Streaming source is not initialized"); } if (!is_writable()) { @@ -1142,8 +1138,8 @@ void Stream::WriteStreamData(const v8::FunctionCallbackInfo& args) { auto view = value.As(); auto length = view->ByteLength(); if (length == 0) return true; - auto entry = CreateEntryFromBuffer( - env, view->Buffer(), view->ByteOffset(), length); + auto entry = + CreateEntryFromBuffer(env, view->Buffer(), view->ByteOffset(), length); if (!entry) { return false; } @@ -1462,7 +1458,6 @@ void Stream::Schedule(Queue* queue) { if (outbound_ && stream_queue_.IsEmpty()) queue->PushBack(this); } - } // namespace quic } // namespace node diff --git a/src/quic/tlscontext.cc b/src/quic/tlscontext.cc index 0bde5a2c5a2..2bed2ad19ad 100644 --- a/src/quic/tlscontext.cc +++ b/src/quic/tlscontext.cc @@ -89,7 +89,7 @@ void EnableTrace(Environment* env, BIOPointer* bio, SSL* ssl) { #endif } -template Opt::* member> +template Opt::*member> bool SetOption(Environment* env, Opt* options, const Local& object, @@ -417,16 +417,14 @@ SSLCtxPointer TLSContext::Initialize() { } if (SSL_CTX_set_max_early_data( - ctx.get(), - options_.enable_early_data ? UINT32_MAX : 0) != 1) { + ctx.get(), options_.enable_early_data ? UINT32_MAX : 0) != 1) { validation_error_ = "Failed to set max early data"; return {}; } // ngtcp2 handles replay protection at the QUIC layer, // so we disable OpenSSL's built-in anti-replay. SSL_CTX_set_options(ctx.get(), - (SSL_OP_ALL & - ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) | + (SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) | SSL_OP_SINGLE_ECDH_USE | SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_ANTI_REPLAY); @@ -451,7 +449,7 @@ SSLCtxPointer TLSContext::Initialize() { SessionTicket::GenerateCallback, SessionTicket::DecryptedCallback, nullptr), - 1); + 1); break; } case Side::CLIENT: {