From: Amos Jeffries Date: Sat, 30 Aug 2025 05:26:44 +0000 (+0000) Subject: Maintenance: C++11 default initializers for Comm::Connection (#2147) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5987200b2e3c609d37bfd850a3cd9e1edda0d415;p=thirdparty%2Fsquid.git Maintenance: C++11 default initializers for Comm::Connection (#2147) --- diff --git a/src/comm/Connection.cc b/src/comm/Connection.cc index f50e80ca5d..ed5c1d3411 100644 --- a/src/comm/Connection.cc +++ b/src/comm/Connection.cc @@ -29,17 +29,6 @@ Comm::IsConnOpen(const Comm::ConnectionPointer &conn) return conn != nullptr && conn->isOpen(); } -Comm::Connection::Connection() : - peerType(HIER_NONE), - fd(-1), - tos(0), - nfmark(0), - flags(COMM_NONBLOCKING), - peer_(nullptr), - startTime_(squid_curtime), - tlsHistory(nullptr) -{} - Comm::Connection::~Connection() { if (fd >= 0) { diff --git a/src/comm/Connection.h b/src/comm/Connection.h index c9065f5b76..a8f99f572f 100644 --- a/src/comm/Connection.h +++ b/src/comm/Connection.h @@ -74,7 +74,7 @@ class Connection: public CodeContext MEMPROXY_CLASS(Comm::Connection); public: - Connection(); + Connection() { noteStart(); } /** Clear the connection properties and close any open socket. */ ~Connection() override; @@ -152,18 +152,18 @@ public: Ip::Address remote; /** Hierarchy code for this connection link */ - hier_code peerType; + hier_code peerType = HIER_NONE; /** Socket used by this connection. Negative if not open. */ - int fd; + int fd = -1; /** Quality of Service TOS values currently sent on this connection */ - tos_t tos; + tos_t tos = 0; /** Netfilter MARK values currently sent on this connection * In case of FTP, the MARK will be sent on data connections as well. */ - nfmark_t nfmark; + nfmark_t nfmark = 0; /** Netfilter CONNMARK value previously retrieved from this connection * In case of FTP, the CONNMARK will NOT be applied to data connections, for one main reason: @@ -174,7 +174,7 @@ public: nfmark_t nfConnmark = 0; /** COMM flags set on this connection */ - int flags; + int flags = COMM_NONBLOCKING; #if USE_SQUID_EUI Eui::Eui48 remoteEui48; @@ -185,13 +185,13 @@ public: private: /** cache_peer data object (if any) */ - CachePeer *peer_; + CachePeer *peer_ = nullptr; /** The time the connection object was created */ time_t startTime_; /** TLS connection details*/ - Security::NegotiationHistory *tlsHistory; + Security::NegotiationHistory *tlsHistory = nullptr; }; std::ostream &operator <<(std::ostream &, const Connection &); diff --git a/src/tests/stub_libcomm.cc b/src/tests/stub_libcomm.cc index e82eca1e9d..5d79420cbb 100644 --- a/src/tests/stub_libcomm.cc +++ b/src/tests/stub_libcomm.cc @@ -20,7 +20,6 @@ void Comm::AcceptLimiter::removeDead(const Comm::TcpAcceptor::Pointer &) STUB void Comm::AcceptLimiter::kick() STUB #include "comm/Connection.h" -Comm::Connection::Connection() STUB Comm::Connection::~Connection() STUB Comm::ConnectionPointer Comm::Connection::cloneProfile() const STUB_RETVAL(nullptr) void Comm::Connection::close() STUB