From 6264adc8d424103c807ce09f3b48df078dfdb57f Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Wed, 2 Jan 2013 03:12:45 -0700 Subject: [PATCH] Address several Coverity issues dealing with noninitialized data members Complete and fix some class constructors, removed redundant htcpReplyData --- src/htcp.cc | 5 +++-- src/htcp.h | 5 +---- src/icp_v2.cc | 7 +++++-- src/ip/QosConfig.cc | 22 +++++++--------------- src/ipc/Kid.cc | 6 ++++-- src/neighbors.cc | 6 +++--- src/peer_select.cc | 10 +++++----- src/ssl/helper.cc | 2 +- 8 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/htcp.cc b/src/htcp.cc index 2c33a680c6..49cc72a2c6 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1088,14 +1088,15 @@ htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from) htcpHandleTstResponse(hdr, buf, sz, from); } -HtcpReplyData::HtcpReplyData() : hdr(hoHtcpReply) +HtcpReplyData::HtcpReplyData() : + hit(0), hdr(hoHtcpReply), msg_id(0), version(0.0) {} static void htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from) { - htcpReplyData htcpReply; + HtcpReplyData htcpReply; cache_key *key = NULL; Ip::Address *peer; diff --git a/src/htcp.h b/src/htcp.h index 631d1c0f5e..cb33473362 100644 --- a/src/htcp.h +++ b/src/htcp.h @@ -57,11 +57,8 @@ public: } cto; }; -/// \bug redundant typedef -typedef class HtcpReplyData htcpReplyData; - /// \ingroup ServerProtocolHTCP -void neighborsHtcpReply(const cache_key *, htcpReplyData *, const Ip::Address &); +void neighborsHtcpReply(const cache_key *, HtcpReplyData *, const Ip::Address &); /// \ingroup ServerProtocolHTCP void htcpOpenPorts(void); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 6b253bcd5f..f0a1e5f456 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -95,10 +95,13 @@ Comm::ConnectionPointer icpIncomingConn = NULL; Comm::ConnectionPointer icpOutgoingConn = NULL; /* icp_common_t */ -_icp_common_t::_icp_common_t() : opcode(ICP_INVALID), version(0), length(0), reqnum(0), flags(0), pad(0), shostid(0) +_icp_common_t::_icp_common_t() : + opcode(ICP_INVALID), version(0), length(0), reqnum(0), + flags(0), pad(0), shostid(0) {} -_icp_common_t::_icp_common_t(char *buf, unsigned int len) +_icp_common_t::_icp_common_t(char *buf, unsigned int len) : + opcode(ICP_INVALID), version(0), reqnum(0), flags(0), pad(0), shostid(0) { if (len < sizeof(_icp_common_t)) { /* mark as invalid */ diff --git a/src/ip/QosConfig.cc b/src/ip/QosConfig.cc index 268584c762..8fd23c8af6 100644 --- a/src/ip/QosConfig.cc +++ b/src/ip/QosConfig.cc @@ -184,22 +184,14 @@ Ip::Qos::doNfmarkLocalHit(const Comm::ConnectionPointer &conn) Ip::Qos::Config Ip::Qos::TheConfig; -Ip::Qos::Config::Config() +Ip::Qos::Config::Config() : tosLocalHit(0), tosSiblingHit(0), tosParentHit(0), + tosMiss(0), tosMissMask(0), preserveMissTos(false), + preserveMissTosMask(0xFF), markLocalHit(0), markSiblingHit(0), + markParentHit(0), markMiss(0), markMissMask(0), + preserveMissMark(false), preserveMissMarkMask(0xFFFFFFFF), + tosToServer(NULL), tosToClient(NULL), nfmarkToServer(NULL), + nfmarkToClient(NULL) { - tosLocalHit = 0; - tosSiblingHit = 0; - tosParentHit = 0; - tosMiss = 0; - tosMissMask = 0; - preserveMissTos = false; - preserveMissTosMask = 0xFF; - markLocalHit = 0; - markSiblingHit = 0; - markParentHit = 0; - markMiss = 0; - markMissMask = 0; - preserveMissMark = false; - preserveMissMarkMask = 0xFFFFFFFF; } void diff --git a/src/ipc/Kid.cc b/src/ipc/Kid.cc index 9ba836d05e..ee54cfb114 100644 --- a/src/ipc/Kid.cc +++ b/src/ipc/Kid.cc @@ -17,7 +17,8 @@ Kid::Kid(): badFailures(0), pid(-1), startTime(0), - isRunning(false) + isRunning(false), + status(0) { } @@ -26,7 +27,8 @@ Kid::Kid(const String& kid_name): badFailures(0), pid(-1), startTime(0), - isRunning(false) + isRunning(false), + status(0) { } diff --git a/src/neighbors.cc b/src/neighbors.cc index 43aa517720..fb937819c0 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -74,7 +74,7 @@ static int peerWouldBePinged(const CachePeer *, HttpRequest *); static void neighborRemove(CachePeer *); static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *); #if USE_HTCP -static void neighborAliveHtcp(CachePeer *, const MemObject *, const htcpReplyData *); +static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *); #endif static void neighborCountIgnored(CachePeer *); static void peerRefreshDNS(void *); @@ -893,7 +893,7 @@ neighborUpdateRtt(CachePeer * p, MemObject * mem) #if USE_HTCP static void -neighborAliveHtcp(CachePeer * p, const MemObject * mem, const htcpReplyData * htcp) +neighborAliveHtcp(CachePeer * p, const MemObject * mem, const HtcpReplyData * htcp) { peerAlive(p); ++ p->stats.pings_acked; @@ -1689,7 +1689,7 @@ dump_peers(StoreEntry * sentry, CachePeer * peers) #if USE_HTCP void -neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const Ip::Address &from) +neighborsHtcpReply(const cache_key * key, HtcpReplyData * htcp, const Ip::Address &from) { StoreEntry *e = Store::Root().get(key); MemObject *mem = NULL; diff --git a/src/peer_select.cc b/src/peer_select.cc index 8b1c8e9254..b707a07ff9 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -72,8 +72,8 @@ static IRCB peerHandlePingReply; static void peerSelectStateFree(ps_state * psstate); static void peerIcpParentMiss(CachePeer *, icp_common_t *, ps_state *); #if USE_HTCP -static void peerHtcpParentMiss(CachePeer *, htcpReplyData *, ps_state *); -static void peerHandleHtcpReply(CachePeer *, peer_t, htcpReplyData *, void *); +static void peerHtcpParentMiss(CachePeer *, HtcpReplyData *, ps_state *); +static void peerHandleHtcpReply(CachePeer *, peer_t, HtcpReplyData *, void *); #endif static int peerCheckNetdbDirect(ps_state * psstate); static void peerGetSomeNeighbor(ps_state *); @@ -836,7 +836,7 @@ peerHandleIcpReply(CachePeer * p, peer_t type, icp_common_t * header, void *data #if USE_HTCP static void -peerHandleHtcpReply(CachePeer * p, peer_t type, htcpReplyData * htcp, void *data) +peerHandleHtcpReply(CachePeer * p, peer_t type, HtcpReplyData * htcp, void *data) { ps_state *psstate = (ps_state *)data; debugs(44, 3, "peerHandleHtcpReply: " << @@ -861,7 +861,7 @@ peerHandleHtcpReply(CachePeer * p, peer_t type, htcpReplyData * htcp, void *data } static void -peerHtcpParentMiss(CachePeer * p, htcpReplyData * htcp, ps_state * ps) +peerHtcpParentMiss(CachePeer * p, HtcpReplyData * htcp, ps_state * ps) { int rtt; @@ -910,7 +910,7 @@ peerHandlePingReply(CachePeer * p, peer_t type, AnyP::ProtocolType proto, void * #if USE_HTCP else if (proto == AnyP::PROTO_HTCP) - peerHandleHtcpReply(p, type, (htcpReplyData *)pingdata, data); + peerHandleHtcpReply(p, type, (HtcpReplyData *)pingdata, data); #endif diff --git a/src/ssl/helper.cc b/src/ssl/helper.cc index 6c8803b99f..f5f522b80d 100644 --- a/src/ssl/helper.cc +++ b/src/ssl/helper.cc @@ -14,7 +14,7 @@ Ssl::Helper * Ssl::Helper::GetInstance() return &sslHelper; } -Ssl::Helper::Helper() +Ssl::Helper::Helper() : ssl_crtd(NULL) { } -- 2.47.2