From: Amos Jeffries Date: Wed, 22 Feb 2017 17:39:44 +0000 (+1300) Subject: Cleanup: convert SBuf to C++11 initialization X-Git-Tag: M-staged-PR71~251 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6bc1ca30b4ae23c71bcef19a1606c0774b88ba83;p=thirdparty%2Fsquid.git Cleanup: convert SBuf to C++11 initialization This should resolve many Coverity uninitialized member warnings caused by the SBuf stub linked to pinger helper being confused with the sbuf/libsbuf.la SBuf constructor definition. --- diff --git a/src/sbuf/SBuf.cc b/src/sbuf/SBuf.cc index d1f9b8697e..2cc50f1cfb 100644 --- a/src/sbuf/SBuf.cc +++ b/src/sbuf/SBuf.cc @@ -36,8 +36,7 @@ SBufStats SBuf::stats; const SBuf::size_type SBuf::npos; const SBuf::size_type SBuf::maxSize; -SBuf::SBuf() - : store_(GetStorePrototype()), off_(0), len_(0) +SBuf::SBuf() : store_(GetStorePrototype()) { debugs(24, 8, id << " created"); ++stats.alloc; @@ -53,8 +52,7 @@ SBuf::SBuf(const SBuf &S) ++stats.live; } -SBuf::SBuf(const std::string &s) - : store_(GetStorePrototype()), off_(0), len_(0) +SBuf::SBuf(const std::string &s) : store_(GetStorePrototype()) { debugs(24, 8, id << " created from std::string"); lowAppend(s.data(),s.length()); @@ -62,8 +60,7 @@ SBuf::SBuf(const std::string &s) ++stats.live; } -SBuf::SBuf(const char *S, size_type n) - : store_(GetStorePrototype()), off_(0), len_(0) +SBuf::SBuf(const char *S, size_type n) : store_(GetStorePrototype()) { append(S,n); ++stats.alloc; @@ -71,8 +68,7 @@ SBuf::SBuf(const char *S, size_type n) ++stats.live; } -SBuf::SBuf(const char *S) - : store_(GetStorePrototype()), off_(0), len_(0) +SBuf::SBuf(const char *S) : store_(GetStorePrototype()) { append(S,npos); ++stats.alloc; diff --git a/src/sbuf/SBuf.h b/src/sbuf/SBuf.h index a02257964e..1cc4658e7c 100644 --- a/src/sbuf/SBuf.h +++ b/src/sbuf/SBuf.h @@ -60,7 +60,7 @@ public: protected: SBufIterator(const SBuf &, size_type); - const char *iter; + const char *iter = nullptr; }; /** Reverse input const_iterator for SBufs @@ -98,14 +98,11 @@ public: /// create an empty (zero-size) SBuf SBuf(); SBuf(const SBuf &S); -#if __cplusplus >= 201103L SBuf(SBuf&& S) : store_(std::move(S.store_)), off_(S.off_), len_(S.len_) { ++stats.moves; - S.store_=NULL; //RefCount supports NULL, and S is about to be destructed - S.off_=0; - S.len_=0; + S.store_ = nullptr; //RefCount supports nullptr, and S is about to be destructed + S.off_ = S.len_ = 0; } -#endif /** Constructor: import c-style string * @@ -639,8 +636,8 @@ private: friend class Locker; MemBlob::Pointer store_; ///< memory block, possibly shared with other SBufs - size_type off_; ///< our content start offset from the beginning of shared store_ - size_type len_; ///< number of our content bytes in shared store_ + size_type off_ = 0; ///< our content start offset from the beginning of shared store_ + size_type len_ = 0; ///< number of our content bytes in shared store_ static SBufStats stats; ///< class-wide statistics /** obtain prototype store