Skip to content

Commit e5023fd

Browse files
committed
quic: Fix cpp linting
1 parent f9442d3 commit e5023fd

5 files changed

Lines changed: 65 additions & 53 deletions

File tree

src/quic/application.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Session::Application : public MemoryRetainer {
221221
virtual bool CloseWebtransportSessionStream(
222222
const Stream& stream,
223223
uint32_t wt_error_code,
224-
const uint8_t *msg,
224+
const uint8_t* msg,
225225
size_t msglen
226226
) {
227227
return false;

src/quic/defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ enum class Direction : uint8_t {
301301
};
302302

303303
enum class StreamType : uint8_t {
304-
QUICSTREAM, // standard quic stream
305-
WTSTREAM, // quic stream associated with webtransport session
304+
QUICSTREAM, // standard quic stream
305+
WTSTREAM, // quic stream associated with webtransport session
306306
};
307307

308308
enum class HeadersKind : uint8_t {

src/quic/http3.cc

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class Http3ApplicationImpl final : public Session::Application {
375375
Debug(&session(),
376376
"HTTP/3 application extending max stream data to %" PRIu64,
377377
max_data);
378-
stream->UpdateWriteDesiredSize(); // the stream might be blocked on js side
378+
stream->UpdateWriteDesiredSize(); // the stream might be blocked on js side
379379
nghttp3_conn_unblock_stream(*this, stream->id());
380380
}
381381

@@ -511,8 +511,9 @@ class Http3ApplicationImpl final : public Session::Application {
511511
code = error.code();
512512
}
513513

514-
int rv = nghttp3_conn_close_stream2(*this, NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET,
515-
stream->id(), code, 0);
514+
int rv = nghttp3_conn_close_stream2(*this,
515+
NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET,
516+
stream->id(), code, 0);
516517
// If the call is successful, Http3Application::OnStreamClose callback will
517518
// be invoked when the stream is ready to be closed. We'll handle destroying
518519
// the actual Stream object there.
@@ -650,18 +651,19 @@ class Http3ApplicationImpl final : public Session::Application {
650651
return false;
651652
}
652653

653-
bool MakeWebtransportStream(const Stream& stream, int64_t sessionid) override {
654+
bool MakeWebtransportStream(const Stream& stream,
655+
int64_t sessionid) override {
654656
Session::SendPendingDataScope send_scope(&session());
655657
static constexpr nghttp3_data_reader reader = {on_read_data_callback};
656-
const nghttp3_data_reader* reader_ptr = &reader; // can use the same reader
658+
const nghttp3_data_reader* reader_ptr = &reader; // can use the same reader
657659

658660
Debug(&session(),
659661
"Make stream %" PRIu64 " webtransport stream of session %" PRIu64,
660662
stream.id(),
661663
sessionid);
662-
// we only need to do this, if we can send data
664+
// we only need to do this, if we can send data
663665
if (stream.is_remote_unidirectional())
664-
return true; // so bail out for remote unidirectional streams
666+
return true; // so bail out for remote unidirectional streams
665667
return nghttp3_conn_open_wt_data_stream(*this,
666668
sessionid,
667669
stream.id(),
@@ -677,9 +679,8 @@ class Http3ApplicationImpl final : public Session::Application {
677679
bool CloseWebtransportSessionStream(
678680
const Stream& stream,
679681
uint32_t wt_error_code,
680-
const uint8_t *msg,
681-
size_t msglen
682-
) override {
682+
const uint8_t* msg,
683+
size_t msglen) override {
683684
Session::SendPendingDataScope send_scope(&session());
684685
Debug(&session(),
685686
"Close webtransport session stream %" PRIu64,
@@ -877,7 +878,7 @@ class Http3ApplicationImpl final : public Session::Application {
877878
return Http3ConnectionPointer(conn);
878879
}
879880

880-
void OnStreamClose(Stream* stream, uint32_t flags,
881+
void OnStreamClose(Stream* stream, uint32_t flags,
881882
error_code rx_app_error_code,
882883
error_code tx_app_error_code) {
883884
if (flags & NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET) {
@@ -1299,32 +1300,36 @@ class Http3ApplicationImpl final : public Session::Application {
12991300
return NGHTTP3_ERR_CALLBACK_FAILURE;
13001301
}
13011302

1302-
static int on_receive_wt_data(nghttp3_conn *conn,
1303+
static int on_receive_wt_data(nghttp3_conn* conn,
13031304
int64_t session_id,
13041305
int64_t stream_id,
1305-
const uint8_t *data,
1306+
const uint8_t* data,
13061307
size_t datalen,
1307-
void *conn_user_data,
1308-
void *stream_user_data) {
1308+
void* conn_user_data,
1309+
void* stream_user_data) {
13091310
NGHTTP3_CALLBACK_SCOPE(app);
13101311
auto& session = app.session();
1311-
if (auto stream = FindOrCreateStream(conn, &session, stream_id)) [[likely]] {
1312+
if (auto stream = FindOrCreateStream(conn,
1313+
&session,
1314+
stream_id)) [[likely]] {
13121315
stream->ReceiveData(data, datalen, Stream::ReceiveDataFlags{});
13131316
return NGTCP2_SUCCESS;
13141317
}
13151318
return NGHTTP3_ERR_CALLBACK_FAILURE;
13161319
}
13171320

1318-
static int on_wt_data_stream_open(nghttp3_conn *conn,
1321+
static int on_wt_data_stream_open(nghttp3_conn* conn,
13191322
int64_t session_id,
13201323
int64_t stream_id,
1321-
void *conn_user_data,
1322-
void *stream_user_data) {
1324+
void* conn_user_data,
1325+
void* stream_user_data) {
13231326
NGHTTP3_CALLBACK_SCOPE(app);
13241327
auto& session = app.session();
1325-
if (auto stream = FindOrCreateStream(conn, &session, stream_id)) [[likely]] {
1328+
if (auto stream = FindOrCreateStream(conn,
1329+
&session,
1330+
stream_id)) [[likely]] {
13261331
if (!app.MakeWebtransportStream(*stream.get(), session_id)) {
1327-
stream->Destroy(); // close stream forcefully, TODO may be use an assert instead?
1332+
stream->Destroy(); // close stream forcefully
13281333
return NGHTTP3_ERR_CALLBACK_FAILURE;
13291334
}
13301335
stream->NotifyWTSession(session_id);
@@ -1333,16 +1338,18 @@ class Http3ApplicationImpl final : public Session::Application {
13331338
return NGHTTP3_ERR_CALLBACK_FAILURE;
13341339
}
13351340

1336-
static int on_recv_wt_close_session(nghttp3_conn *conn,
1341+
static int on_recv_wt_close_session(nghttp3_conn* conn,
13371342
int64_t session_id,
13381343
uint32_t wt_error_code,
1339-
const uint8_t *msg,
1344+
const uint8_t* msg,
13401345
size_t msglen,
1341-
void *conn_user_data,
1342-
void *stream_user_data) {
1346+
void* conn_user_data,
1347+
void* stream_user_data) {
13431348
NGHTTP3_CALLBACK_SCOPE(app);
13441349
auto& session = app.session();
1345-
if (auto stream = FindOrCreateStream(conn, &session, session_id)) [[likely]] {
1350+
if (auto stream = FindOrCreateStream(conn,
1351+
&session,
1352+
session_id)) [[likely]] {
13461353
stream->NotifyWTSessionClose(wt_error_code, msg, msglen);
13471354
return NGTCP2_SUCCESS;
13481355
}
@@ -1531,7 +1538,7 @@ class Http3ApplicationImpl final : public Session::Application {
15311538

15321539
static constexpr nghttp3_callbacks kCallbacks = {
15331540
on_acked_stream_data,
1534-
nullptr, //nghttp3_stream_close (deprecated)
1541+
nullptr, // nghttp3_stream_close (deprecated)
15351542
on_receive_data,
15361543
on_deferred_consume,
15371544
on_begin_headers,

src/quic/streams.cc

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -487,26 +487,27 @@ struct Stream::Impl {
487487
JS_METHOD(MakeWebtransportStream) {
488488
Stream* stream;
489489
ASSIGN_OR_RETURN_UNWRAP(&stream, args.This());
490-
CHECK(args.Length() > 0);
490+
CHECK_GT(args.Length(), 0);
491491
CHECK(args[0]->IsObject());
492492
Stream* session;
493493
ASSIGN_OR_RETURN_UNWRAP(&session, args[0].As<v8::Object>());
494494
if (stream->is_pending()) {
495495
stream->EnqueuePendingWebtransportStream(session->id());
496496
return args.GetReturnValue().Set(true);
497497
}
498-
args.GetReturnValue().Set(stream->session().application().MakeWebtransportStream(
499-
*stream,
500-
session->id()
501-
));
498+
args.GetReturnValue().Set(stream->session()
499+
.application()
500+
.MakeWebtransportStream(
501+
*stream,
502+
session->id()));
502503
}
503504

504505
// Closes a webtransport session stream,
505506
// also closes connected data streams
506507
JS_METHOD(CloseWebtransportSessionStream) {
507508
Stream* stream;
508509
ASSIGN_OR_RETURN_UNWRAP(&stream, args.This());
509-
CHECK(args.Length() > 0);
510+
CHECK_GT(args.Length(), 0);
510511
uint32_t wt_error_code = 0;
511512
if (args.Length() > 0) {
512513
CHECK(args[0]->IsUint32());
@@ -520,15 +521,17 @@ struct Stream::Impl {
520521
const size_t length = msgstr->Utf8LengthV2(args.GetIsolate());
521522
msg = new uint8_t[length];
522523
msgstr->WriteUtf8V2(
523-
args.GetIsolate(), reinterpret_cast<char*>(msg), length, String::WriteFlags::kNone);
524+
args.GetIsolate(),
525+
reinterpret_cast<char*>(msg), length, String::WriteFlags::kNone);
524526
msglen = std::min<size_t>(length, 1024);
525527
}
526-
args.GetReturnValue().Set(stream->session().application().CloseWebtransportSessionStream(
527-
*stream,
528-
wt_error_code,
529-
msg,
530-
msglen
531-
));
528+
args.GetReturnValue().Set(stream->session()
529+
.application()
530+
.CloseWebtransportSessionStream(
531+
*stream,
532+
wt_error_code,
533+
msg,
534+
msglen));
532535
if (msg) {
533536
delete[] msg;
534537
}
@@ -1634,7 +1637,7 @@ void Stream::BeginHeaders(HeadersKind kind) {
16341637
headers_length_ = 0;
16351638
headers_.clear();
16361639
set_headers_kind(kind);
1637-
state()->session_id = -1; // we know we are not a wt stream
1640+
state()->session_id = -1; // we know we are not a wt stream
16381641
}
16391642

16401643
void Stream::set_headers_kind(HeadersKind kind) {
@@ -1661,7 +1664,7 @@ void Stream::NotifyWTSession(stream_id session_id) {
16611664
}
16621665

16631666
void Stream::NotifyWTSessionClose(uint32_t wt_error_code,
1664-
const uint8_t *msg,
1667+
const uint8_t* msg,
16651668
size_t msglen) {
16661669
EmitWTSessionClose(wt_error_code, msg, msglen);
16671670
}
@@ -2045,19 +2048,20 @@ void Stream::EmitSessionid(stream_id session_id) {
20452048
MakeCallback(BindingData::Get(env()).stream_sessionid_callback(), 1, &sid);
20462049
}
20472050

2048-
2051+
20492052
void Stream::EmitWTSessionClose(uint32_t wt_error_code,
2050-
const uint8_t *msg,
2051-
size_t msglen) {
2053+
const uint8_t* msg,
2054+
size_t msglen) {
20522055
if (!env()->can_call_into_js() || !state()->wants_wtsessionclose) return;
20532056
CallbackScope<Stream> cb_scope(this);
20542057
Local<Value> argv[] = {
20552058
Integer::NewFromUnsigned(env()->isolate(),
20562059
wt_error_code),
2057-
String::NewFromUtf8(env()->isolate(), reinterpret_cast<const char *>(msg),
2060+
String::NewFromUtf8(env()->isolate(),
2061+
reinterpret_cast<const char *>(msg),
20582062
v8::NewStringType::kNormal, msglen).ToLocalChecked()
20592063
};
2060-
MakeCallback(BindingData::Get(env()).stream_wtsessionclose_callback(),
2064+
MakeCallback(BindingData::Get(env()).stream_wtsessionclose_callback(),
20612065
arraysize(argv), argv);
20622066
}
20632067

src/quic/streams.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,10 @@ class Stream final : public AsyncWrap,
373373
// Currently only http/3 can have a session stream in WebTransport
374374
void NotifyWTSession(stream_id session_id);
375375

376-
// Currently only http/3 can have a session stream that receives a close capsule
376+
// Currently only http/3 can have a session stream
377+
// that receives a close capsule
377378
void NotifyWTSessionClose(uint32_t wt_error_code,
378-
const uint8_t *msg,
379+
const uint8_t* msg,
379380
size_t msglen);
380381

381382
// TODO(@jasnell): Implement MemoryInfo to track outbound_, inbound_,
@@ -455,7 +456,7 @@ class Stream final : public AsyncWrap,
455456

456457
// delivers the content of the close capsule
457458
void EmitWTSessionClose(uint32_t wt_error_code,
458-
const uint8_t *msg,
459+
const uint8_t* msg,
459460
size_t msglen);
460461

461462
void NotifyReadableEnded(error_code code);

0 commit comments

Comments
 (0)