Skip to content

Commit

Permalink
Merge pull request #259 from ngtcp2/clang-format-fuzz
Browse files Browse the repository at this point in the history
clang-format files under fuzz
  • Loading branch information
tatsuhiro-t authored Sep 14, 2024
2 parents a872b6c + c6669de commit 3e14e6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ clang-format:
CLANGFORMAT=`git config --get clangformat.binary`; \
test -z $${CLANGFORMAT} && CLANGFORMAT="clang-format"; \
$${CLANGFORMAT} -i lib/*.{c,h} tests/*.{c,h} lib/includes/nghttp3/*.h \
examples/*.{cc,h}
examples/*.{cc,h} fuzz/*.cc
2 changes: 1 addition & 1 deletion fuzz/fuzz_http3serverreq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

nghttp3_conn *conn;
auto rv =
nghttp3_conn_server_new(&conn, &callbacks, &settings, nullptr, nullptr);
nghttp3_conn_server_new(&conn, &callbacks, &settings, nullptr, nullptr);
if (rv != 0) {
return 0;
}
Expand Down
20 changes: 10 additions & 10 deletions fuzz/fuzz_qpackdecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,30 @@ class Decoder {
std::priority_queue<std::shared_ptr<Request>,
std::vector<std::shared_ptr<Request>>,
std::greater<std::shared_ptr<Request>>>
blocked_reqs_;
blocked_reqs_;
size_t max_dtable_size_;
size_t max_blocked_;
};

Request::Request(int64_t stream_id, const nghttp3_buf *buf)
: buf(*buf), stream_id(stream_id) {
: buf(*buf), stream_id(stream_id) {
auto mem = nghttp3_mem_default();
nghttp3_qpack_stream_context_new(&sctx, stream_id, mem);
}

Request::~Request() { nghttp3_qpack_stream_context_del(sctx); }

Decoder::Decoder(size_t max_dtable_size, size_t max_blocked)
: mem_(nghttp3_mem_default()),
dec_(nullptr),
max_dtable_size_(max_dtable_size),
max_blocked_(max_blocked) {}
: mem_(nghttp3_mem_default()),
dec_(nullptr),
max_dtable_size_(max_dtable_size),
max_blocked_(max_blocked) {}

Decoder::~Decoder() { nghttp3_qpack_decoder_del(dec_); }

int Decoder::init() {
if (auto rv = nghttp3_qpack_decoder_new(&dec_, max_dtable_size_, max_blocked_,
mem_);
if (auto rv =
nghttp3_qpack_decoder_new(&dec_, max_dtable_size_, max_blocked_, mem_);
rv != 0) {
return -1;
}
Expand All @@ -87,7 +87,7 @@ int Decoder::init() {

int Decoder::read_encoder(nghttp3_buf *buf) {
auto nread =
nghttp3_qpack_decoder_read_encoder(dec_, buf->pos, nghttp3_buf_len(buf));
nghttp3_qpack_decoder_read_encoder(dec_, buf->pos, nghttp3_buf_len(buf));
if (nread < 0) {
return -1;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ std::tuple<Headers, int> Decoder::read_request(Request &req) {

for (;;) {
auto nread = nghttp3_qpack_decoder_read_request(
dec_, req.sctx, &nv, &flags, req.buf.pos, nghttp3_buf_len(&req.buf), 1);
dec_, req.sctx, &nv, &flags, req.buf.pos, nghttp3_buf_len(&req.buf), 1);
if (nread < 0) {
return {Headers{}, -1};
}
Expand Down

0 comments on commit 3e14e6f

Please sign in to comment.