]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix several uninitilized member issues
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 Jan 2015 04:13:30 +0000 (20:13 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 Jan 2015 04:13:30 +0000 (20:13 -0800)
* Digest auth header field-value parser

* HTTP header statistics state data

* logformat parser token data

src/HttpHdrCc.cc
src/HttpHeader.cc
src/HttpHeader.h
src/HttpHeaderStat.h
src/format/TokenTableEntry.h

index b8d21ca77f0fccdb8466b343a117f82a1192e2a8..af09e78e12df7c096459071862bfcbc07f43f931 100644 (file)
 #include <map>
 
 /* a row in the table used for parsing cache control header and statistics */
-typedef struct {
+class HttpHeaderCcFields
+{
+public:
+    HttpHeaderCcFields() : name(NULL), id(CC_BADHDR), stat() {}
+    HttpHeaderCcFields(const char *aName, http_hdr_cc_type aTypeId) : name(aName), id(aTypeId) {}
+    // nothing to do as name is a pointer to global static string
+    ~HttpHeaderCcFields() {}
+
     const char *name;
     http_hdr_cc_type id;
     HttpHeaderFieldStat stat;
-} HttpHeaderCcFields;
+
+private:
+    HttpHeaderCcFields(const HttpHeaderCcFields &); // not implemented
+    HttpHeaderCcFields &operator =(const HttpHeaderCcFields &); // not implemented
+};
 
 /* order must match that of enum http_hdr_cc_type. The constraint is verified at initialization time */
 static HttpHeaderCcFields CcAttrs[CC_ENUM_END] = {
index 7913511518e99fe49e94b3e47c84a993272bbe97..59dad66fc8096528d0370d0f98cb8203c7931bbf 100644 (file)
@@ -322,13 +322,18 @@ static http_hdr_type HopByHopHeadersArr[] = {
 };
 
 /* header accounting */
+// NP: keep in sync with enum http_hdr_owner_type
 static HttpHeaderStat HttpHeaderStats[] = {
-    {"all"},
+    {/*hoNone*/ "all", NULL},
 #if USE_HTCP
-    {"HTCP reply"},
+    {/*hoHtcpReply*/ "HTCP reply", &ReplyHeadersMask},
 #endif
-    {"request"},
-    {"reply"}
+    {/*hoRequest*/ "request", &RequestHeadersMask},
+    {/*hoReply*/ "reply", &ReplyHeadersMask}
+#if USE_OPENSSL
+    /* hoErrorDetail */
+#endif
+    /* hoEnd */
 };
 static int HttpHeaderStatCount = countof(HttpHeaderStats);
 
@@ -343,7 +348,6 @@ class StoreEntry;
 
 static void httpHeaderNoteParsedEntry(http_hdr_type id, String const &value, int error);
 
-static void httpHeaderStatInit(HttpHeaderStat * hs, const char *label);
 static void httpHeaderStatDump(const HttpHeaderStat * hs, StoreEntry * e);
 
 /** store report about current header usage and other stats */
@@ -364,7 +368,6 @@ httpHeaderRegisterWithCacheManager(void)
 void
 httpHeaderInitModule(void)
 {
-    int i;
     /* check that we have enough space for masks */
     assert(8 * sizeof(HttpHeaderMask) >= HDR_ENUM_END);
     /* all headers must be described */
@@ -390,18 +393,8 @@ httpHeaderInitModule(void)
     httpHeaderMaskInit(&HopByHopHeadersMask, 0);
     httpHeaderCalcMask(&HopByHopHeadersMask, HopByHopHeadersArr, countof(HopByHopHeadersArr));
 
-    /* init header stats */
+    /* header stats initialized by class constructor */
     assert(HttpHeaderStatCount == hoReply + 1);
-    for (i = 0; i < HttpHeaderStatCount; ++i)
-        httpHeaderStatInit(HttpHeaderStats + i, HttpHeaderStats[i].label);
-
-    HttpHeaderStats[hoRequest].owner_mask = &RequestHeadersMask;
-
-    HttpHeaderStats[hoReply].owner_mask = &ReplyHeadersMask;
-
-#if USE_HTCP
-    HttpHeaderStats[hoHtcpReply].owner_mask = &ReplyHeadersMask;
-#endif
 
     /* init dependent modules */
     httpHdrCcInitModule();
@@ -419,19 +412,6 @@ httpHeaderCleanModule(void)
     httpHdrScCleanModule();
 }
 
-static void
-httpHeaderStatInit(HttpHeaderStat * hs, const char *label)
-{
-    assert(hs);
-    assert(label);
-    memset(hs, 0, sizeof(HttpHeaderStat));
-    hs->label = label;
-    hs->hdrUCountDistr.enumInit(32);    /* not a real enum */
-    hs->fieldTypeDistr.enumInit(HDR_ENUM_END);
-    hs->ccTypeDistr.enumInit(CC_ENUM_END);
-    hs->scTypeDistr.enumInit(SC_ENUM_END);
-}
-
 /*
  * HttpHeader Implementation
  */
index 9e0e0a16102d0745455915de159da5980b74ca5a..487bd688e5282f4f71d16273b1db38739debce6f 100644 (file)
@@ -55,10 +55,18 @@ typedef enum {
     hoEnd
 } http_hdr_owner_type;
 
-// currently a POD
 class HttpHeaderFieldAttrs
 {
 public:
+    HttpHeaderFieldAttrs() : name(NULL), id(HDR_BAD_HDR), type(ftInvalid) {}
+    HttpHeaderFieldAttrs(const char *aName, http_hdr_type anId, field_type aType = ftInvalid) : name(aName), id(anId), type(aType) {}
+#if __cplusplus >= 201103L
+    HttpHeaderFieldAttrs(const HttpHeaderFieldAttrs &) = default;
+    HttpHeaderFieldAttrs(HttpHeaderFieldAttrs &&) = default;
+#endif
+    // nothing to do as name is a pointer to global const string
+    ~HttpHeaderFieldAttrs() {}
+
     const char *name;
     http_hdr_type id;
     field_type type;
index e441efd4983a32e1fa325475f521e3f60c51e62e..c01e26c11ce8ac4c71fcae43a23debe5d4556e65 100644 (file)
 
 #include "StatHist.h"
 
-/// per header statistics
+/// HTTP per header statistics
 class HttpHeaderStat
 {
 public:
+    HttpHeaderStat() :
+            label(NULL),
+            owner_mask(NULL),
+            parsedCount(0),
+            ccParsedCount(0),
+            scParsedCount(0),
+            destroyedCount(0),
+            busyDestroyedCount(0)
+    {
+        hdrUCountDistr.enumInit(32);    /* not a real enum */
+        fieldTypeDistr.enumInit(HDR_ENUM_END);
+        ccTypeDistr.enumInit(CC_ENUM_END);
+        scTypeDistr.enumInit(SC_ENUM_END);
+    }
+
+    HttpHeaderStat(const char *aLabel, HttpHeaderMask *aMask) :
+            label(aLabel),
+            owner_mask(aMask),
+            parsedCount(0),
+            ccParsedCount(0),
+            scParsedCount(0),
+            destroyedCount(0),
+            busyDestroyedCount(0)
+    {
+        assert(label);
+        hdrUCountDistr.enumInit(32);    /* not a real enum */
+        fieldTypeDistr.enumInit(HDR_ENUM_END);
+        ccTypeDistr.enumInit(CC_ENUM_END);
+        scTypeDistr.enumInit(SC_ENUM_END);
+    }
+
+    // nothing to destruct as label is a pointer to global const string
+    // and owner_mask is a pointer to global static array
+    ~HttpHeaderStat() {}
+
     const char *label;
     HttpHeaderMask *owner_mask;
 
index c30da86b6de23a5c576d230cf6ce49bec1326b84..3e88e3f07267a87c36f12cc0a57c36863750786b 100644 (file)
@@ -30,6 +30,11 @@ namespace Format
 class TokenTableEntry
 {
 public:
+    TokenTableEntry() : configTag(NULL), tokenType(LFT_NONE), options(0) {}
+    TokenTableEntry(const char *aTag, const ByteCode_t &aType) : configTag(aTag), tokenType(aType), options(0) {}
+    // nothing to destruct configTag is pointer to global const string
+    ~TokenTableEntry() {}
+
     /// the config file ASCII representation for this token
     /// just the base tag bytes, excluding any option syntax bytes
     const char *configTag;
@@ -39,6 +44,10 @@ public:
 
     /// 32-bit mask? of options affecting the output display of this token
     uint32_t options;
+
+private:
+    TokenTableEntry(const TokenTableEntry&); // not implemented
+    TokenTableEntry &operator =(const TokenTableEntry&); // not implemented
 };
 
 } // namespace Format