Skip to content

Commit c32d465

Browse files
committed
quic: fixup linting issues
1 parent 399b1a2 commit c32d465

File tree

13 files changed

+77
-69
lines changed

13 files changed

+77
-69
lines changed

src/quic/application.cc

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include "application.h"
44
#include <async_wrap-inl.h>
55
#include <debug_utils-inl.h>
6+
#include <ngtcp2/ngtcp2.h>
67
#include <node_bob.h>
78
#include <node_sockaddr-inl.h>
8-
#include <ngtcp2/ngtcp2.h>
99
#include <uv.h>
1010
#include <v8.h>
1111
#include "defs.h"
@@ -246,8 +246,7 @@ void Session::Application::SendPendingData() {
246246

247247
// The maximum number of packets to send in this call to SendPendingData.
248248
const size_t max_packet_count = std::min(
249-
kMaxPackets,
250-
ngtcp2_conn_get_send_quantum(*session_) / max_packet_size);
249+
kMaxPackets, ngtcp2_conn_get_send_quantum(*session_) / max_packet_size);
251250

252251
// The number of packets that have been sent in this call to SendPendingData.
253252
size_t packet_send_count = 0;
@@ -295,11 +294,12 @@ void Session::Application::SendPendingData() {
295294
Debug(session_, "Application using stream data: %s", stream_data);
296295

297296
// Awesome, let's write our packet!
298-
ssize_t nwrite = WriteVStream(&path, pos, &ndatalen, max_packet_size, stream_data);
297+
ssize_t nwrite =
298+
WriteVStream(&path, pos, &ndatalen, max_packet_size, stream_data);
299299
Debug(session_, "Application accepted %zu bytes into packet", ndatalen);
300300

301-
// A negative nwrite value indicates either an error or that there is more data
302-
// to write into the packet.
301+
// A negative nwrite value indicates either an error or that there is more
302+
// data to write into the packet.
303303
if (nwrite < 0) {
304304
switch (nwrite) {
305305
case NGTCP2_ERR_STREAM_DATA_BLOCKED: {
@@ -317,7 +317,8 @@ void Session::Application::SendPendingData() {
317317
// Indicates that the writable side of the stream should be closed
318318
// locally or the stream is being reset. In either case, we can't send
319319
// any stream data!
320-
Debug(session_, "Stream %" PRIi64 " should be closed for writing",
320+
Debug(session_,
321+
"Stream %" PRIi64 " should be closed for writing",
321322
stream_data.id);
322323
// ndatalen = -1 means that no stream data was accepted into the
323324
// packet, which is what we want here.
@@ -341,7 +342,8 @@ void Session::Application::SendPendingData() {
341342

342343
// Some other type of error happened.
343344
DCHECK_EQ(ndatalen, -1);
344-
Debug(session_, "Application encountered error while writing packet: %s",
345+
Debug(session_,
346+
"Application encountered error while writing packet: %s",
345347
ngtcp2_strerror(nwrite));
346348
session_->SetLastError(QuicError::ForNgtcp2Error(nwrite));
347349
packet->Done(UV_ECANCELED);
@@ -363,14 +365,16 @@ void Session::Application::SendPendingData() {
363365
size_t datalen = pos - begin;
364366
if (datalen) {
365367
Debug(session_, "Packet has %zu bytes to send", datalen);
366-
// At least some data had been written into the packet. We should send it.
368+
// At least some data had been written into the packet. We should send
369+
// it.
367370
packet->Truncate(datalen);
368371
session_->Send(packet, path);
369372
} else {
370373
packet->Done(UV_ECANCELED);
371374
}
372375

373-
// If there was stream data selected, we should reschedule it to try sending again.
376+
// If there was stream data selected, we should reschedule it to try
377+
// sending again.
374378
if (stream_data.id >= 0) ResumeStream(stream_data.id);
375379

376380
return session_->UpdatePacketTxTime();
@@ -403,18 +407,17 @@ ssize_t Session::Application::WriteVStream(PathStorage* path,
403407
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
404408
if (stream_data.fin) flags |= NGTCP2_WRITE_STREAM_FLAG_FIN;
405409
ngtcp2_pkt_info pi;
406-
return ngtcp2_conn_writev_stream(
407-
*session_,
408-
&path->path,
409-
&pi,
410-
dest,
411-
max_packet_size,
412-
ndatalen,
413-
flags,
414-
stream_data.id,
415-
stream_data.buf,
416-
stream_data.count,
417-
uv_hrtime());
410+
return ngtcp2_conn_writev_stream(*session_,
411+
&path->path,
412+
&pi,
413+
dest,
414+
max_packet_size,
415+
ndatalen,
416+
flags,
417+
stream_data.id,
418+
stream_data.buf,
419+
stream_data.count,
420+
uv_hrtime());
418421
}
419422

420423
// The DefaultApplication is the default implementation of Session::Application

src/quic/data.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "nghttp3/nghttp3.h"
22
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
33

4-
#include "data.h"
54
#include <env-inl.h>
65
#include <memory_tracker-inl.h>
76
#include <ngtcp2/ngtcp2.h>
87
#include <node_sockaddr-inl.h>
98
#include <string_bytes.h>
109
#include <v8.h>
10+
#include "data.h"
1111
#include "defs.h"
1212
#include "util.h"
1313

@@ -48,7 +48,9 @@ std::string Path::ToString() const {
4848
return res;
4949
}
5050

51-
PathStorage::PathStorage() { Reset(); }
51+
PathStorage::PathStorage() {
52+
Reset();
53+
}
5254
PathStorage::operator ngtcp2_path() {
5355
return path;
5456
}
@@ -281,16 +283,14 @@ void QuicError::MemoryInfo(MemoryTracker* tracker) const {
281283
tracker->TrackField("reason", reason_.length());
282284
}
283285

284-
QuicError QuicError::ForTransport(error_code code,
285-
std::string reason) {
286+
QuicError QuicError::ForTransport(error_code code, std::string reason) {
286287
QuicError error(std::move(reason));
287288
ngtcp2_ccerr_set_transport_error(
288289
&error.error_, code, error.reason_c_str(), reason.length());
289290
return error;
290291
}
291292

292-
QuicError QuicError::ForApplication(error_code code,
293-
std::string reason) {
293+
QuicError QuicError::ForApplication(error_code code, std::string reason) {
294294
QuicError error(std::move(reason));
295295
ngtcp2_ccerr_set_application_error(
296296
&error.error_, code, error.reason_c_str(), reason.length());

src/quic/data.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ class QuicError final : public MemoryRetainer {
120120
static error_code liberr_to_code(int liberr);
121121
static error_code h3_liberr_to_code(int liberr);
122122

123-
static QuicError ForTransport(error_code code,
124-
std::string reason = "");
125-
static QuicError ForApplication(error_code code,
126-
std::string reason = "");
123+
static QuicError ForTransport(error_code code, std::string reason = "");
124+
static QuicError ForApplication(error_code code, std::string reason = "");
127125
static QuicError ForVersionNegotiation(std::string reason = "");
128126
static QuicError ForIdleClose(std::string reason = "");
129127
static QuicError ForNgtcp2Error(int code, std::string reason = "");

src/quic/defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include <aliased_struct.h>
44
#include <env.h>
5-
#include <node_errors.h>
6-
#include <ngtcp2/ngtcp2.h>
75
#include <nghttp3/nghttp3.h>
6+
#include <ngtcp2/ngtcp2.h>
7+
#include <node_errors.h>
88
#include <uv.h>
99
#include <v8.h>
1010
#include <limits>

src/quic/endpoint.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ std::string Endpoint::Options::ToString() const {
336336

337337
auto ccalg = ([&] {
338338
switch (cc_algorithm) {
339-
#define V(name, label) case NGTCP2_CC_ALGO_##name: return #label;
339+
#define V(name, label) \
340+
case NGTCP2_CC_ALGO_##name: \
341+
return #label;
340342
ENDPOINT_CC(V)
341343
#undef V
342344
}
@@ -615,7 +617,7 @@ void Endpoint::InitPerIsolate(IsolateData* data, Local<ObjectTemplate> target) {
615617

616618
void Endpoint::InitPerContext(Realm* realm, Local<Object> target) {
617619
#define V(name, str) \
618-
NODE_DEFINE_CONSTANT(target, CC_ALGO_##name); \
620+
NODE_DEFINE_CONSTANT(target, CC_ALGO_##name); \
619621
NODE_DEFINE_STRING_CONSTANT(target, "CC_ALGO_" #name "_STR", #str);
620622
ENDPOINT_CC(V)
621623
#undef V

src/quic/endpoint.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class Endpoint final : public AsyncWrap, public Packet::Listener {
3838
static constexpr uint64_t DEFAULT_MAX_STATELESS_RESETS = 10;
3939
static constexpr uint64_t DEFAULT_MAX_RETRY_LIMIT = 10;
4040

41-
#define V(name, _) \
42-
static constexpr auto CC_ALGO_##name = NGTCP2_CC_ALGO_##name;
41+
#define V(name, _) static constexpr auto CC_ALGO_##name = NGTCP2_CC_ALGO_##name;
4342
ENDPOINT_CC(V)
4443
#undef V
4544

src/quic/packet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Packet final : public ReqWrap<uv_udp_send_t> {
7777
const SocketAddress& destination,
7878
std::shared_ptr<Data> data);
7979

80-
DISALLOW_COPY_AND_MOVE(Packet);
80+
DISALLOW_COPY_AND_MOVE(Packet)
8181

8282
const SocketAddress& destination() const;
8383
size_t length() const;

src/quic/preferredaddress.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ Maybe<PreferredAddress::Policy> PreferredAddress::tryGetPolicy(
146146
return Just(PreferredAddress::Policy::USE);
147147
}
148148
if (value->IsUint32()) {
149-
switch(value.As<Uint32>()->Value()) {
150-
case PREFERRED_ADDRESS_IGNORE: return Just(Policy::IGNORE);
151-
case PREFERRED_ADDRESS_USE: return Just(Policy::USE);
149+
switch (value.As<Uint32>()->Value()) {
150+
case PREFERRED_ADDRESS_IGNORE:
151+
return Just(Policy::IGNORE);
152+
case PREFERRED_ADDRESS_USE:
153+
return Just(Policy::USE);
152154
}
153155
}
154156
THROW_ERR_INVALID_ARG_VALUE(env, "invalid preferred address policy");

src/quic/session.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ bool SetOption(Environment* env,
226226
const v8::Local<Object>& object,
227227
const v8::Local<String>& name) {
228228
Local<Value> value;
229-
PreferredAddress::Policy policy =
230-
PreferredAddress::Policy::USE;
229+
PreferredAddress::Policy policy = PreferredAddress::Policy::USE;
231230
if (!object->Get(env->context(), name).ToLocal(&value) ||
232231
!PreferredAddress::tryGetPolicy(env, value).To(&policy)) {
233232
return false;
@@ -472,10 +471,11 @@ bool Session::HasInstance(Environment* env, Local<Value> value) {
472471
return GetConstructorTemplate(env)->HasInstance(value);
473472
}
474473

475-
BaseObjectPtr<Session> Session::Create(Endpoint* endpoint,
476-
const Config& config,
477-
TLSContext* tls_context,
478-
std::optional<SessionTicket>& ticket) {
474+
BaseObjectPtr<Session> Session::Create(
475+
Endpoint* endpoint,
476+
const Config& config,
477+
TLSContext* tls_context,
478+
const std::optional<SessionTicket>& ticket) {
479479
Local<Object> obj;
480480
if (!GetConstructorTemplate(endpoint->env())
481481
->InstanceTemplate()
@@ -492,7 +492,7 @@ Session::Session(Endpoint* endpoint,
492492
v8::Local<v8::Object> object,
493493
const Config& config,
494494
TLSContext* tls_context,
495-
std::optional<SessionTicket>& session_ticket)
495+
const std::optional<SessionTicket>& session_ticket)
496496
: AsyncWrap(endpoint->env(), object, AsyncWrap::PROVIDER_QUIC_SESSION),
497497
stats_(env()->isolate()),
498498
state_(env()->isolate()),
@@ -2027,8 +2027,8 @@ struct Session::Impl {
20272027
to_string(level),
20282028
session->config().dcid);
20292029

2030-
return session->application().Start() ?
2031-
NGTCP2_SUCCESS : NGTCP2_ERR_CALLBACK_FAILURE;
2030+
return session->application().Start() ? NGTCP2_SUCCESS
2031+
: NGTCP2_ERR_CALLBACK_FAILURE;
20322032
}
20332033

20342034
static int on_receive_stateless_reset(ngtcp2_conn* conn,
@@ -2085,8 +2085,8 @@ struct Session::Impl {
20852085
"Receiving TX key for level %d for dcid %s",
20862086
to_string(level),
20872087
session->config().dcid);
2088-
return session->application().Start() ?
2089-
NGTCP2_SUCCESS : NGTCP2_ERR_CALLBACK_FAILURE;
2088+
return session->application().Start() ? NGTCP2_SUCCESS
2089+
: NGTCP2_ERR_CALLBACK_FAILURE;
20902090
}
20912091

20922092
static int on_receive_version_negotiation(ngtcp2_conn* conn,

src/quic/session.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,18 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source {
205205
static void InitPerContext(Realm* env, v8::Local<v8::Object> target);
206206
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
207207

208-
static BaseObjectPtr<Session> Create(Endpoint* endpoint,
209-
const Config& config,
210-
TLSContext* tls_context,
211-
std::optional<SessionTicket>& ticket);
208+
static BaseObjectPtr<Session> Create(
209+
Endpoint* endpoint,
210+
const Config& config,
211+
TLSContext* tls_context,
212+
const std::optional<SessionTicket>& ticket);
212213

213214
// Really should be private but MakeDetachedBaseObject needs visibility.
214215
Session(Endpoint* endpoint,
215216
v8::Local<v8::Object> object,
216217
const Config& config,
217218
TLSContext* tls_context,
218-
std::optional<SessionTicket>& ticket);
219+
const std::optional<SessionTicket>& ticket);
219220
~Session() override;
220221

221222
uint32_t version() const;
@@ -289,7 +290,7 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source {
289290
Session* session;
290291
explicit SendPendingDataScope(Session* session);
291292
explicit SendPendingDataScope(const BaseObjectPtr<Session>& session);
292-
DISALLOW_COPY_AND_MOVE(SendPendingDataScope);
293+
DISALLOW_COPY_AND_MOVE(SendPendingDataScope)
293294
~SendPendingDataScope();
294295
};
295296

0 commit comments

Comments
 (0)