From 5d662a4e97bba64be6ccc46d818a3a06e384c6c8 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Sat, 4 Sep 2021 11:54:24 +0200 Subject: [PATCH] dnsdist: Replace useless switch() with an if statement --- pdns/dnsdistdist/dnsdist-nghttp2.cc | 41 +++++++++++++---------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index 6b933168a2..2819d159e2 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -707,30 +707,25 @@ int DoHConnectionToBackend::on_header_callback(nghttp2_session* session, const n DoHConnectionToBackend* conn = reinterpret_cast(user_data); const std::string status(":status"); - switch (frame->hd.type) { - case NGHTTP2_HEADERS: - if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) { - //cerr<<"got header for "<hd.stream_id<<":"<(name), namelen)<(value), valuelen)<d_currentStreams.find(frame->hd.stream_id); - if (stream == conn->d_currentStreams.end()) { - vinfolog("Unable to match the stream ID %d to a known one!", frame->hd.stream_id); - conn->d_connectionDied = true; - return NGHTTP2_ERR_CALLBACK_FAILURE; - } - try { - stream->second.d_responseCode = pdns_stou(std::string(reinterpret_cast(value), valuelen)); - } - catch (...) { - vinfolog("Error parsing the status header for stream ID %d", frame->hd.stream_id); - conn->d_connectionDied = true; - return NGHTTP2_ERR_CALLBACK_FAILURE; - } + if (frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_RESPONSE) { + //cerr<<"got header for "<hd.stream_id<<":"<(name), namelen)<(value), valuelen)<d_currentStreams.find(frame->hd.stream_id); + if (stream == conn->d_currentStreams.end()) { + vinfolog("Unable to match the stream ID %d to a known one!", frame->hd.stream_id); + conn->d_connectionDied = true; + return NGHTTP2_ERR_CALLBACK_FAILURE; + } + try { + stream->second.d_responseCode = pdns_stou(std::string(reinterpret_cast(value), valuelen)); + } + catch (...) { + vinfolog("Error parsing the status header for stream ID %d", frame->hd.stream_id); + conn->d_connectionDied = true; + return NGHTTP2_ERR_CALLBACK_FAILURE; } - - break; } } return 0; -- 2.47.2