]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: convert class SBufStats to C++11 initialization
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 23 Feb 2017 11:11:13 +0000 (00:11 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 23 Feb 2017 11:11:13 +0000 (00:11 +1300)
 ... and to Squid coding style layout.

This also resolves uninitialized variable in pinger issue detected by
Coverity Scan. Issue 1228696.

src/sbuf/Stats.cc
src/sbuf/Stats.h
src/tests/stub_SBuf.cc

index 63562373e48fa389253e2f8e4818199d9d63fa5f..7d20ab024ab27791f9641a5ec593ba4ec8c120a3 100644 (file)
 
 #include <iostream>
 
-SBufStats::SBufStats()
-    : alloc(0), allocCopy(0), allocFromCString(0),
-      assignFast(0), clear(0), append(0), moves(0), toStream(0), setChar(0),
-      getChar(0), compareSlow(0), compareFast(0), copyOut(0),
-      rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0),
-      caseChange(0), cowFast(0), cowSlow(0), live(0)
-{}
-
 SBufStats&
 SBufStats::operator +=(const SBufStats& ss)
 {
index 00b76f047945c8f59fe492918d1d30d5513be9a6..7c280a58837d6927f42a3f94946088b44acadf1d 100644 (file)
 class SBufStats
 {
 public:
-    uint64_t alloc; ///<number of calls to SBuf constructors
-    uint64_t allocCopy; ///<number of calls to SBuf copy-constructor
-    uint64_t allocFromCString; ///<number of copy-allocations from c-strings
-    uint64_t assignFast; ///<number of no-copy assignment operations
-    uint64_t clear; ///<number of clear operations
-    uint64_t append; ///<number of append operations
-    uint64_t moves; ///<number of move constructions/assignments
-    uint64_t toStream;  ///<number of write operations to ostreams
-    uint64_t setChar; ///<number of calls to setAt
-    uint64_t getChar; ///<number of calls to at() and operator[]
-    uint64_t compareSlow; ///<number of comparison operations requiring data scan
-    uint64_t compareFast; ///<number of comparison operations not requiring data scan
-    uint64_t copyOut; ///<number of data-copies to other forms of buffers
-    uint64_t rawAccess; ///<number of accesses to raw contents
-    uint64_t nulTerminate; ///<number of c_str() terminations
-    uint64_t chop;  ///<number of chop operations
-    uint64_t trim;  ///<number of trim operations
-    uint64_t find;  ///<number of find operations
-    uint64_t caseChange; ///<number of toUpper and toLower operations
-    uint64_t cowFast; ///<number of cow operations not actually requiring a copy
-    uint64_t cowSlow; ///<number of cow operations requiring a copy
-    uint64_t live;  ///<number of currently-allocated SBuf
-
     ///Dump statistics to an ostream.
     std::ostream& dump(std::ostream &os) const;
-    SBufStats();
 
     SBufStats& operator +=(const SBufStats&);
+
+public:
+    uint64_t alloc = 0; ///<number of calls to SBuf constructors
+    uint64_t allocCopy = 0; ///<number of calls to SBuf copy-constructor
+    uint64_t allocFromCString = 0; ///<number of copy-allocations from c-strings
+    uint64_t assignFast = 0; ///<number of no-copy assignment operations
+    uint64_t clear = 0; ///<number of clear operations
+    uint64_t append = 0; ///<number of append operations
+    uint64_t moves = 0; ///<number of move constructions/assignments
+    uint64_t toStream = 0;  ///<number of write operations to ostreams
+    uint64_t setChar = 0; ///<number of calls to setAt
+    uint64_t getChar = 0; ///<number of calls to at() and operator[]
+    uint64_t compareSlow = 0; ///<number of comparison operations requiring data scan
+    uint64_t compareFast = 0; ///<number of comparison operations not requiring data scan
+    uint64_t copyOut = 0; ///<number of data-copies to other forms of buffers
+    uint64_t rawAccess = 0; ///<number of accesses to raw contents
+    uint64_t nulTerminate = 0; ///<number of c_str() terminations
+    uint64_t chop = 0;  ///<number of chop operations
+    uint64_t trim = 0;  ///<number of trim operations
+    uint64_t find = 0;  ///<number of find operations
+    uint64_t caseChange = 0; ///<number of toUpper and toLower operations
+    uint64_t cowFast = 0; ///<number of cow operations not actually requiring a copy
+    uint64_t cowSlow = 0; ///<number of cow operations requiring a copy
+    uint64_t live = 0;  ///<number of currently-allocated SBuf
 };
 
 #endif /* SQUID_SBUF_STATS_H */
index e0904fad6c9e999e3daf46707405e0810c8c313b..d1bca7d84adaa396b943227a26affa783049a052 100644 (file)
@@ -19,7 +19,6 @@ SBufStats SBuf::stats;
 const SBuf::size_type SBuf::npos;
 const SBuf::size_type SBuf::maxSize;
 
-SBufStats::SBufStats() {}
 std::ostream& SBufStats::dump(std::ostream &os) const STUB_RETVAL(os)
 SBufStats& SBufStats::operator +=(const SBufStats&) STUB_RETVAL(*this)