Skip to content

Commit

Permalink
dnsdist: Fix more clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Jan 23, 2024
1 parent e053dc9 commit 94e3db7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pdns/bpf-filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static void bpf_check_map_sizes(int descriptor, uint32_t expectedKeySize, uint32
}
}

// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
static int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
int max_entries, int map_flags)
{
Expand Down Expand Up @@ -137,15 +138,15 @@ static int bpf_get_next_key(int descriptor, void *key, void *next_key)
}

static int bpf_prog_load(enum bpf_prog_type prog_type,
const struct bpf_insn *insns, int prog_len,
const struct bpf_insn *insns, size_t prog_len,
const char *license, int kern_version)
{
char log_buf[65535];
union bpf_attr attr;
memset(&attr, 0, sizeof(attr));
attr.prog_type = prog_type;
attr.insns = ptr_to_u64((void *) insns);
attr.insn_cnt = prog_len / sizeof(struct bpf_insn);
attr.insn_cnt = static_cast<int>(prog_len / sizeof(struct bpf_insn));
attr.license = ptr_to_u64((void *) license);
attr.log_buf = ptr_to_u64(log_buf);
attr.log_size = sizeof(log_buf);
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdist-tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ IncomingTCPConnectionState::QueryProcessingResult IncomingTCPConnectionState::ha
{
/* this pointer will be invalidated the second the buffer is resized, don't hold onto it! */
const dnsheader_aligned dnsHeader(query.data());
if (!checkQueryHeaders(*dnsHeader.get(), *d_ci.cs)) {
if (!checkQueryHeaders(*dnsHeader, *d_ci.cs)) {
return QueryProcessingResult::InvalidHeaders;
}

Expand Down
8 changes: 4 additions & 4 deletions pdns/dnsdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1705,9 +1705,9 @@ bool assignOutgoingUDPQueryToBackend(std::shared_ptr<DownstreamState>& downstrea
}

try {
int fd = downstream->pickSocketForSending();
int descriptor = downstream->pickSocketForSending();
if (actuallySend) {
dnsQuestion.ids.backendFD = fd;
dnsQuestion.ids.backendFD = descriptor;
}
dnsQuestion.ids.origID = queryID;
dnsQuestion.ids.forwardedOverUDP = true;
Expand All @@ -1726,7 +1726,7 @@ bool assignOutgoingUDPQueryToBackend(std::shared_ptr<DownstreamState>& downstrea

/* you can't touch ids or du after this line, unless the call returned a non-negative value,
because it might already have been freed */
ssize_t ret = udpClientSendRequestToBackend(downstream, fd, query);
ssize_t ret = udpClientSendRequestToBackend(downstream, descriptor, query);

if (ret < 0) {
failed = true;
Expand Down Expand Up @@ -1799,7 +1799,7 @@ static void processUDPQuery(ClientState& cs, LocalHolders& holders, const struct
const dnsheader_aligned dnsHeader(query.data());
queryId = ntohs(dnsHeader->id);

if (!checkQueryHeaders(*dnsHeader.get(), cs)) {
if (!checkQueryHeaders(*dnsHeader, cs)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/doh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ static void processDOHQuery(DOHUnitUniquePtr&& unit, bool inMainThread = false)
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
const dnsheader_aligned dnsHeader(unit->query.data());

if (!checkQueryHeaders(*dnsHeader.get(), clientState)) {
if (!checkQueryHeaders(*dnsHeader, clientState)) {
unit->status_code = 400;
handleImmediateResponse(std::move(unit), "DoH invalid headers");
return;
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/doh3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ static void processDOH3Query(DOH3UnitUniquePtr&& doh3Unit)
/* don't keep that pointer around, it will be invalidated if the buffer is ever resized */
dnsheader_aligned dnsHeader(unit->query.data());

if (!checkQueryHeaders(*dnsHeader.get(), clientState)) {
if (!checkQueryHeaders(*dnsHeader, clientState)) {
dnsdist::PacketMangling::editDNSHeaderFromPacket(unit->query, [](dnsheader& header) {
header.rcode = RCode::ServFail;
header.qr = true;
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/doq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static void processDOQQuery(DOQUnitUniquePtr&& doqUnit)
/* don't keep that pointer around, it will be invalidated if the buffer is ever resized */
dnsheader_aligned dnsHeader(unit->query.data());

if (!checkQueryHeaders(*dnsHeader.get(), clientState)) {
if (!checkQueryHeaders(*dnsHeader, clientState)) {
dnsdist::PacketMangling::editDNSHeaderFromPacket(unit->query, [](dnsheader& header) {
header.rcode = RCode::ServFail;
header.qr = true;
Expand Down

0 comments on commit 94e3db7

Please sign in to comment.