]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: fix various uninitialized class members
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Sep 2014 07:18:13 +0000 (00:18 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Sep 2014 07:18:13 +0000 (00:18 -0700)
Also, simplify some destructors. xfree() is faster than
safe_free() and both are ok in a destructor.

  Detected by Coverity Scan. Issue 740527, 740532, 740533,
    740534, 740563, 1241964

src/StoreMetaUnpacker.cc
src/adaptation/icap/History.cc
src/adaptation/icap/Options.cc
src/adaptation/icap/Xaction.cc
src/external_acl.cc
src/fs/ufs/UFSSwapDir.cc

index 447f86296350bfe8f22ef620901a8775db95d734..8576086d0340c0a9714a05f3a3c6719be8f4ff70 100644 (file)
@@ -61,9 +61,16 @@ StoreMetaUnpacker::getBufferLength()
     memcpy(hdr_len, &buf[1], sizeof(int));
 }
 
-StoreMetaUnpacker::StoreMetaUnpacker (char const *aBuffer, ssize_t aLen, int *anInt) : buf (aBuffer), buflen(aLen), hdr_len(anInt), position(1 + sizeof(int))
+StoreMetaUnpacker::StoreMetaUnpacker(char const *aBuffer, ssize_t aLen, int *anInt) :
+        buf(aBuffer),
+        buflen(aLen),
+        hdr_len(anInt),
+        position(1 + sizeof(int)),
+        type('\0'),
+        length(0),
+        tail(NULL)
 {
-    assert (aBuffer != NULL);
+    assert(aBuffer != NULL);
 }
 
 void
index ee32fefafbc46cb2485cec94d26d51d3ab629dd0..a32b96619e57ef96ffecaec65a00ca29e30ec0bf 100644 (file)
 #include "SquidTime.h"
 
 Adaptation::Icap::History::History():
-        logType(LOG_TAG_NONE), req_sz(0),
-        pastTime(0), concurrencyLevel(0)
+        logType(LOG_TAG_NONE),
+        req_sz(0),
+        pastTime(0),
+        concurrencyLevel(0)
 {
+    memset(&currentStart, 0, sizeof(currentStart));
 }
 
 void Adaptation::Icap::History::start(const char *context)
index 2c3317c2bd4ee3dde5aac10b971a1f197a6c0bca..15e33e2343c90836c73d8fd7445a4db04ae5d132 100644 (file)
 #include "StrList.h"
 #include "wordlist.h"
 
-Adaptation::Icap::Options::Options(): error("unconfigured"),
-        max_connections(-1), allow204(false),
+Adaptation::Icap::Options::Options() :
+        error("unconfigured"),
+        max_connections(-1),
+        allow204(false),
         allow206(false),
-        preview(-1), theTTL(-1)
+        preview(-1),
+        theTTL(-1),
+        theTimestamp(0)
 {
     theTransfers.preview.name = "Transfer-Preview";
     theTransfers.preview.kind = xferPreview;
index 23a3c764141844d7f55fe10ed3f78f34a0bfb9c3..b69d0401594e92eab80bc771264c2ce6c098cda7 100644 (file)
@@ -32,8 +32,6 @@
 #include "SquidConfig.h"
 #include "SquidTime.h"
 
-//CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, Xaction);
-
 Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::ServiceRep::Pointer &aService):
         AsyncJob(aTypeName),
         Adaptation::Initiate(aTypeName),
@@ -42,13 +40,18 @@ Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::Serv
         attempts(0),
         connection(NULL),
         theService(aService),
-        commBuf(NULL), commBufSize(0),
+        commBuf(NULL),
+        commBufSize(0),
         commEof(false),
         reuseConnection(true),
         isRetriable(true),
         isRepeatable(true),
         ignoreLastWrite(false),
-        connector(NULL), reader(NULL), writer(NULL), closer(NULL),
+        stopReason(NULL),
+        connector(NULL),
+        reader(NULL),
+        writer(NULL),
+        closer(NULL),
         alep(new AccessLogEntry),
         al(*alep),
         cs(NULL)
@@ -58,6 +61,8 @@ Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::Serv
     icapRequest = new HttpRequest;
     HTTPMSGLOCK(icapRequest);
     icap_tr_start = current_time;
+    memset(&icap_tio_start, 0, sizeof(icap_tio_start));
+    memset(&icap_tio_finish, 0, sizeof(icap_tio_finish));
 }
 
 Adaptation::Icap::Xaction::~Xaction()
index 8c0ba8a632cf8cb0be69304b0953b9d0dda1f55c..cf9842418b65ee0eec7081a8691a984312b3fca5 100644 (file)
@@ -72,7 +72,7 @@ public:
     typedef RefCount<external_acl_format> Pointer;
     MEMPROXY_CLASS(external_acl_format);
 
-    external_acl_format() : header(NULL), member(NULL), separator(' ') {}
+    external_acl_format() : type(Format::LFT_NONE), header(NULL), member(NULL), separator(' '), header_id(HDR_BAD_HDR) {}
     ~external_acl_format() {
         xfree(header);
         xfree(member);
index 6fab4f0a7c934eeb845204dd9a0b31443c923a65..52179c90a99b8162b9f3584e5ca71959b848aac2 100644 (file)
@@ -304,7 +304,19 @@ Fs::Ufs::UFSSwapDir::create()
     createSwapSubDirs();
 }
 
-Fs::Ufs::UFSSwapDir::UFSSwapDir(char const *aType, const char *anIOType) : SwapDir(aType), IO(NULL), map(new FileMap()), suggest(0), swaplog_fd (-1), currentIOOptions(new ConfigOptionVector()), ioType(xstrdup(anIOType)), cur_size(0), n_disk_objects(0)
+Fs::Ufs::UFSSwapDir::UFSSwapDir(char const *aType, const char *anIOType) :
+        SwapDir(aType),
+        IO(NULL),
+        fsdata(NULL),
+        map(new FileMap()),
+        suggest(0),
+        l1(16),
+        l2(256),
+        swaplog_fd(-1),
+        currentIOOptions(new ConfigOptionVector()),
+        ioType(xstrdup(anIOType)),
+        cur_size(0),
+        n_disk_objects(0)
 {
     /* modulename is only set to disk modules that are built, by configure,
      * so the Find call should never return NULL here.
@@ -318,7 +330,7 @@ Fs::Ufs::UFSSwapDir::~UFSSwapDir()
         file_close(swaplog_fd);
         swaplog_fd = -1;
     }
-    safe_free(ioType);
+    xfree(ioType);
     delete map;
     delete IO;
     delete currentIOOptions;