From: Axel Viala Date: Sun, 11 Dec 2022 15:12:44 +0000 (+0100) Subject: clang-tidy: uninitialized variables explicitly defaulted. X-Git-Tag: dnsdist-1.8.0-rc1~140^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12313%2Fhead;p=thirdparty%2Fpdns.git clang-tidy: uninitialized variables explicitly defaulted. Also pass to one declaration per line at one site. --- diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 78389057ac..b042ede33a 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -66,7 +66,8 @@ void ZoneParserTNG::stackFile(const std::string& fname) std::error_code ec (err, std::generic_category()); throw std::system_error(ec, "Unable to open file '" + fname + "': " + stringerror(err)); } - struct stat st; + + struct stat st = {}; if (fstat(fd, &st) == -1) { int err = errno; close(fd); @@ -132,7 +133,7 @@ unsigned int ZoneParserTNG::makeTTLFromZone(const string& str) if(str.empty()) return 0; - unsigned int val; + unsigned int val = 0; try { pdns::checked_stoi_into(val, str); } @@ -278,9 +279,11 @@ static void chopComment(string& line) { if(line.find(';')==string::npos) return; - string::size_type pos, len = line.length(); - bool inQuote=false; - for(pos = 0 ; pos < len; ++pos) { + + string::size_type pos = 0; + auto len = line.length(); + bool inQuote = false; + for(; pos < len; ++pos) { if(line[pos]=='\\') pos++; else if(line[pos]=='"')