]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: convert SBuf to C++11 initialization
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Feb 2017 17:39:44 +0000 (06:39 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Feb 2017 17:39:44 +0000 (06:39 +1300)
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.

src/sbuf/SBuf.cc
src/sbuf/SBuf.h

index d1f9b8697ea3e32c84c1dc9a64febe26e7ef955c..2cc50f1cfb74c4fa77c665ba04679dffd5eaf662 100644 (file)
@@ -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;
index a02257964e088296de5f648393f436f33aa54dd2..1cc4658e7ce41e6d4967942f2183163e27a5b3fc 100644 (file)
@@ -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