Skip to content

Commit 40f9134

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

File tree

15 files changed

+79
-72
lines changed

15 files changed

+79
-72
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/cid.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "quic/defs.h"
21
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
32
#include "cid.h"
43
#include <crypto/crypto_util.h>
54
#include <memory_tracker-inl.h>
65
#include <node_mutex.h>
76
#include <string_bytes.h>
7+
#include "quic/defs.h"
88

99
namespace node {
1010
namespace quic {

src/quic/data.cc

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

4-
#include "data.h"
53
#include <env-inl.h>
64
#include <memory_tracker-inl.h>
75
#include <ngtcp2/ngtcp2.h>
86
#include <node_sockaddr-inl.h>
97
#include <string_bytes.h>
108
#include <v8.h>
9+
#include "data.h"
1110
#include "defs.h"
1211
#include "util.h"
1312

@@ -48,7 +47,9 @@ std::string Path::ToString() const {
4847
return res;
4948
}
5049

51-
PathStorage::PathStorage() { Reset(); }
50+
PathStorage::PathStorage() {
51+
Reset();
52+
}
5253
PathStorage::operator ngtcp2_path() {
5354
return path;
5455
}
@@ -281,16 +282,14 @@ void QuicError::MemoryInfo(MemoryTracker* tracker) const {
281282
tracker->TrackField("reason", reason_.length());
282283
}
283284

284-
QuicError QuicError::ForTransport(error_code code,
285-
std::string reason) {
285+
QuicError QuicError::ForTransport(error_code code, std::string reason) {
286286
QuicError error(std::move(reason));
287287
ngtcp2_ccerr_set_transport_error(
288288
&error.error_, code, error.reason_c_str(), reason.length());
289289
return error;
290290
}
291291

292-
QuicError QuicError::ForApplication(error_code code,
293-
std::string reason) {
292+
QuicError QuicError::ForApplication(error_code code, std::string reason) {
294293
QuicError error(std::move(reason));
295294
ngtcp2_ccerr_set_application_error(
296295
&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/http3.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class Http3Application final : public Session::Application {
367367
}
368368
}
369369
}
370-
DCHECK_NOT_NULL(stream_data.buf);
370+
DCHECK_NOT_NULL(data->buf);
371371
return 0;
372372
}
373373

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");

0 commit comments

Comments
 (0)