From: Axel Viala Date: Fri, 2 Sep 2022 20:38:34 +0000 (+0200) Subject: clang-tidy: DynListener::getLine. X-Git-Tag: dnsdist-1.8.0-rc1~220^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae278782556d82946be692af9a6ea52f4a30089;p=thirdparty%2Fpdns.git clang-tidy: DynListener::getLine. Fix founds with: - [readability-implicit-bool-conversion] - pdns/dynlistener.cc:256 - pdns/dynlistener.cc:272:8 - [readability-container-data-pointer] - pdns/dynlistener.cc:240:19 - pdns/dynlistener.cc:245:25 - pdns/dynlistener.cc:256:17 - dns/dynlistener.cc:263:17 - [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions] - pdns/dynlistener.cc:240:29 - pdns/dynlistener.cc:256:27 Avoided to fix `if` related to avoid making too much noise. --- diff --git a/pdns/dynlistener.cc b/pdns/dynlistener.cc index 63d06bd368..70a9270a61 100644 --- a/pdns/dynlistener.cc +++ b/pdns/dynlistener.cc @@ -214,7 +214,7 @@ string DynListener::getLine() vector mesg; mesg.resize(1024000); - ssize_t len; + ssize_t len = 0; ComboAddress remote; socklen_t remlen=remote.getSocklen(); @@ -237,12 +237,12 @@ string DynListener::getLine() std::shared_ptr fp=std::shared_ptr(fdopen(dup(d_client), "r"), fclose); if(d_tcp) { - if(!fgets(&mesg[0], mesg.size(), fp.get())) { + if (fgets(mesg.data(), static_cast(mesg.size()), fp.get()) == nullptr) { g_log<(mesg.size()), fp.get()) == nullptr) { + if (errno) { g_log<