From 6c0f3bcf28ac3bec9b34aa7f5c7b275bb0329c2d Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 9 Dec 2024 18:57:41 -0800 Subject: [PATCH] clang-tidy: use default member init Signed-off-by: Rosen Penev --- pdns/axfr-retriever.cc | 6 +++--- pdns/axfr-retriever.hh | 2 +- pdns/bindparserclasses.hh | 31 ++++++++++++++----------------- pdns/comment.hh | 7 ++----- pdns/dnswriter.cc | 6 +++--- pdns/dnswriter.hh | 2 +- pdns/inflighter.cc | 7 ++++--- pdns/logger.cc | 2 +- pdns/logger.hh | 13 +++++-------- pdns/mplexer.hh | 5 +---- pdns/rcpgenerator.cc | 3 ++- pdns/rcpgenerator.hh | 2 +- pdns/signingpipe.cc | 5 ++--- pdns/signingpipe.hh | 8 ++++---- pdns/webserver.cc | 4 ++-- pdns/webserver.hh | 2 +- pdns/ws-auth.cc | 6 ++---- pdns/ws-auth.hh | 2 +- pdns/zoneparser-tng.hh | 5 +++-- 19 files changed, 53 insertions(+), 65 deletions(-) diff --git a/pdns/axfr-retriever.cc b/pdns/axfr-retriever.cc index 6b87f5bd968f..1c814f56d37c 100644 --- a/pdns/axfr-retriever.cc +++ b/pdns/axfr-retriever.cc @@ -31,11 +31,11 @@ using pdns::resolver::parseResult; AXFRRetriever::AXFRRetriever(const ComboAddress& remote, const DNSName& domain, - const TSIGTriplet& tt, + const TSIGTriplet& tt, const ComboAddress* laddr, size_t maxReceivedBytes, - uint16_t timeout) - : d_buf(65536), d_tsigVerifier(tt, remote, d_trc), d_receivedBytes(0), d_maxReceivedBytes(maxReceivedBytes) + uint16_t timeout) : + d_buf(65536), d_tsigVerifier(tt, remote, d_trc), d_maxReceivedBytes(maxReceivedBytes) { ComboAddress local; if (laddr != nullptr) { diff --git a/pdns/axfr-retriever.hh b/pdns/axfr-retriever.hh index 81362b754b5a..18e37f6c5da4 100644 --- a/pdns/axfr-retriever.hh +++ b/pdns/axfr-retriever.hh @@ -51,6 +51,6 @@ class AXFRRetriever : public boost::noncopyable TSIGRecordContent d_trc; TSIGTCPVerifier d_tsigVerifier; - size_t d_receivedBytes; + size_t d_receivedBytes{0}; size_t d_maxReceivedBytes; }; diff --git a/pdns/bindparserclasses.hh b/pdns/bindparserclasses.hh index 1063de98ecb2..655367abdfef 100644 --- a/pdns/bindparserclasses.hh +++ b/pdns/bindparserclasses.hh @@ -32,9 +32,6 @@ class BindDomainInfo { public: - BindDomainInfo() : hadFileDirective(false), d_dev(0), d_ino(0) - {} - void clear() { name=DNSName(); @@ -50,10 +47,10 @@ public: vector primaries; set alsoNotify; string type; - bool hadFileDirective; - - dev_t d_dev; - ino_t d_ino; + bool hadFileDirective{false}; + + dev_t d_dev{0}; + ino_t d_ino{0}; bool operator<(const BindDomainInfo& b) const { @@ -66,14 +63,14 @@ extern FILE *yyin; class BindParser { public: - BindParser() : d_dir("."), d_verbose(false) - { - yyin=0; - extern int include_stack_ptr; - include_stack_ptr=0; - - bind_directory=d_dir.c_str(); - } + BindParser() + { + yyin = 0; + extern int include_stack_ptr; + include_stack_ptr = 0; + + bind_directory = d_dir.c_str(); + } ~BindParser() { if(yyin) { @@ -90,9 +87,9 @@ class BindParser void addAlsoNotify(const string &host); set & getAlsoNotify() { return this->alsoNotify; } private: - string d_dir; + string d_dir{"."}; typedef map zonedomain_t; set alsoNotify; vector d_zonedomains; - bool d_verbose; + bool d_verbose{false}; }; diff --git a/pdns/comment.hh b/pdns/comment.hh index 1608cffec816..b121e1c5166f 100644 --- a/pdns/comment.hh +++ b/pdns/comment.hh @@ -27,15 +27,12 @@ class Comment { public: - Comment() : modified_at(0), domain_id(0) {}; - ~Comment() = default; - // data DNSName qname; //!< the name of the associated RRset, for example: www.powerdns.com - time_t modified_at; + time_t modified_at{0}; string account; //!< account last updating this comment string content; //!< The actual comment. Example: blah blah - int domain_id; + int domain_id{0}; QType qtype; //!< qtype of the associated RRset, ie A, CNAME, MX etc }; diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index 96a66a1a8bbe..5ee38dd75754 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -40,9 +40,9 @@ */ - -template GenericDNSPacketWriter::GenericDNSPacketWriter(Container& content, const DNSName& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) - : d_content(content), d_qname(qname), d_canonic(false), d_lowerCase(false) +template +GenericDNSPacketWriter::GenericDNSPacketWriter(Container& content, const DNSName& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) : + d_content(content), d_qname(qname) { d_content.clear(); dnsheader dnsheader; diff --git a/pdns/dnswriter.hh b/pdns/dnswriter.hh index adccd8365b6e..14696df943f1 100644 --- a/pdns/dnswriter.hh +++ b/pdns/dnswriter.hh @@ -173,7 +173,7 @@ private: uint16_t d_truncatemarker; // end of header, for truncate DNSResourceRecord::Place d_recordplace; - bool d_canonic, d_lowerCase, d_compress{false}; + bool d_canonic{false}, d_lowerCase{false}, d_compress{false}; }; using DNSPacketWriter = GenericDNSPacketWriter>; diff --git a/pdns/inflighter.cc b/pdns/inflighter.cc index e770ea4c4aec..6bdc6d74b0e5 100644 --- a/pdns/inflighter.cc +++ b/pdns/inflighter.cc @@ -44,7 +44,8 @@ struct TimeTag{}; template class Inflighter { public: - Inflighter(Container& c, SenderReceiver& sr) : d_container(c), d_sr(sr), d_init(false) + Inflighter(Container& c, SenderReceiver& sr) : + d_container(c), d_sr(sr) { d_burst = 2; d_maxInFlight = 5; @@ -99,8 +100,8 @@ template class Inflighter ttdwatch_t d_ttdWatch; typename Container::iterator d_iter; - bool d_init; - + bool d_init{false}; + uint64_t d_unexpectedResponse, d_timeouts; }; diff --git a/pdns/logger.cc b/pdns/logger.cc index c31651552deb..52a5f08f72fe 100644 --- a/pdns/logger.cc +++ b/pdns/logger.cc @@ -165,7 +165,7 @@ void Logger::setName(const string& _name) } Logger::Logger(string n, int facility) : - name(std::move(n)), flags(LOG_PID | LOG_NDELAY), d_facility(facility), d_loglevel(Logger::None), consoleUrgency(Error), opened(false), d_disableSyslog(false) + name(std::move(n)), flags(LOG_PID | LOG_NDELAY), d_facility(facility) { open(); } diff --git a/pdns/logger.hh b/pdns/logger.hh index 9a84661442c1..d1581809c4f3 100644 --- a/pdns/logger.hh +++ b/pdns/logger.hh @@ -138,11 +138,8 @@ public: private: struct PerThread { - PerThread() : - d_urgency(Info) - {} string d_output; - Urgency d_urgency; + Urgency d_urgency{Info}; }; PerThread& getPerThread(); void open(); @@ -151,10 +148,10 @@ private: string name; int flags; int d_facility; - Urgency d_loglevel; - Urgency consoleUrgency; - bool opened; - bool d_disableSyslog; + Urgency d_loglevel{Logger::None}; + Urgency consoleUrgency{Error}; + bool opened{false}; + bool d_disableSyslog{false}; bool d_timestamps{true}; bool d_prefixed{false}; // this used to prefix the loglevel, but now causes formatting like structured logging }; diff --git a/pdns/mplexer.hh b/pdns/mplexer.hh index e23982d78552..3f22a4f85f37 100644 --- a/pdns/mplexer.hh +++ b/pdns/mplexer.hh @@ -70,9 +70,6 @@ protected: }; public: - FDMultiplexer() : - d_inrun(false) - {} virtual ~FDMultiplexer() = default; // The maximum number of events processed in a single run, not the maximum of watched descriptors @@ -296,7 +293,7 @@ protected: callbackmap_t; callbackmap_t d_readCallbacks, d_writeCallbacks; - bool d_inrun; + bool d_inrun{false}; void accountingAddFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter, const struct timeval* ttd) { diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index fb5869dd126d..db5e48933c31 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -36,7 +36,8 @@ #include "base64.hh" #include "namespaces.hh" -RecordTextReader::RecordTextReader(string str, DNSName zone) : d_string(std::move(str)), d_zone(std::move(zone)), d_pos(0) +RecordTextReader::RecordTextReader(string str, DNSName zone) : + d_string(std::move(str)), d_zone(std::move(zone)) { /* remove whitespace */ if(!d_string.empty() && ( dns_isspace(*d_string.begin()) || dns_isspace(*d_string.rbegin()) )) diff --git a/pdns/rcpgenerator.hh b/pdns/rcpgenerator.hh index a550177d51a2..914a353aa884 100644 --- a/pdns/rcpgenerator.hh +++ b/pdns/rcpgenerator.hh @@ -77,7 +77,7 @@ public: private: string d_string; DNSName d_zone; - string::size_type d_pos; + string::size_type d_pos{0}; string::size_type d_end; void skipSpaces(); }; diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 25f3d59b9f97..f2464c11b079 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -59,9 +59,8 @@ catch(...) { return nullptr; } -ChunkedSigningPipe::ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) - : d_signed(0), d_queued(0), d_outstanding(0), d_numworkers(workers), d_submitted(0), d_signer(std::move(signerName)), - d_maxchunkrecords(maxChunkRecords), d_threads(d_numworkers), d_mustSign(mustSign), d_final(false) +ChunkedSigningPipe::ChunkedSigningPipe(DNSName signerName, bool mustSign, unsigned int workers, unsigned int maxChunkRecords) : + d_signed(0), d_numworkers(workers), d_signer(std::move(signerName)), d_maxchunkrecords(maxChunkRecords), d_threads(d_numworkers), d_mustSign(mustSign) { d_rrsetToSign = make_unique(); d_chunks.push_back(vector()); // load an empty chunk diff --git a/pdns/signingpipe.hh b/pdns/signingpipe.hh index c72b54178641..d76ebda730c3 100644 --- a/pdns/signingpipe.hh +++ b/pdns/signingpipe.hh @@ -49,8 +49,8 @@ public: unsigned int getReady() const; std::atomic d_signed; - unsigned int d_queued; - unsigned int d_outstanding; + unsigned int d_queued{0}; + unsigned int d_outstanding{0}; private: void flushToSign(); @@ -63,7 +63,7 @@ private: void worker(int fd); unsigned int d_numworkers; - unsigned int d_submitted; + unsigned int d_submitted{0}; std::unique_ptr d_rrsetToSign; std::deque< std::vector > d_chunks; @@ -77,5 +77,5 @@ private: vector d_threads; bool d_mustSign; - bool d_final; + bool d_final{false}; }; diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 58fb65c0ff16..20213ce5cb79 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -587,8 +587,8 @@ WebServer::WebServer(string listenaddress, int port) : d_listenaddress(std::move(listenaddress)), d_port(port), d_server(nullptr), - d_maxbodysize(2*1024*1024), - d_connectiontimeout(5) + d_maxbodysize(2 * 1024 * 1024) + { YaHTTP::Router::Map("OPTIONS", "/<*url>", [](YaHTTP::Request *req, YaHTTP::Response *resp) { // look for url in routes diff --git a/pdns/webserver.hh b/pdns/webserver.hh index 5b83d70712e9..8d5c42e75e16 100644 --- a/pdns/webserver.hh +++ b/pdns/webserver.hh @@ -289,7 +289,7 @@ protected: std::unique_ptr d_webserverPassword{nullptr}; ssize_t d_maxbodysize; // in bytes - int d_connectiontimeout; // in seconds + int d_connectiontimeout{5}; // in seconds NetmaskGroup d_acl; diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index e0713e623ce3..76c22e022f13 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -101,10 +101,8 @@ static const std::set atApexTypes = {QType::SOA, QType::DNSKEY}; static const std::set nonApexTypes = {QType::DS}; AuthWebServer::AuthWebServer() : - d_start(time(nullptr)), - d_min10(0), - d_min5(0), - d_min1(0) + d_start(time(nullptr)) + { if (arg().mustDo("webserver") || arg().mustDo("api")) { d_ws = std::make_unique(arg()["webserver-address"], arg().asNum("webserver-port")); diff --git a/pdns/ws-auth.hh b/pdns/ws-auth.hh index 4eb539e76544..f456ed37a84b 100644 --- a/pdns/ws-auth.hh +++ b/pdns/ws-auth.hh @@ -61,7 +61,7 @@ private: void statThread(StatBag& stats); time_t d_start; - double d_min10, d_min5, d_min1; + double d_min10{0}, d_min5{0}, d_min1{0}; Ewma d_queries, d_cachehits, d_cachemisses; Ewma d_qcachehits, d_qcachemisses; unique_ptr d_ws{nullptr}; diff --git a/pdns/zoneparser-tng.hh b/pdns/zoneparser-tng.hh index b50e86ec6658..977fcb768210 100644 --- a/pdns/zoneparser-tng.hh +++ b/pdns/zoneparser-tng.hh @@ -60,10 +60,11 @@ private: unsigned makeTTLFromZone(const std::string& str); struct filestate { - filestate(FILE* fp, string filename) : d_fp(fp), d_filename(std::move(filename)), d_lineno(0){} + filestate(FILE* fp, string filename) : + d_fp(fp), d_filename(std::move(filename)) {} FILE *d_fp; string d_filename; - int d_lineno; + int d_lineno{0}; }; parts_t d_parts;