]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleaned up net_db structures. Made Coverity happier? (#27)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 22 Jul 2017 03:47:06 +0000 (21:47 -0600)
committerGitHub <noreply@github.com>
Sat, 22 Jul 2017 03:47:06 +0000 (21:47 -0600)
Fixes false positive by Coverity Scan. Issue 1415048 (RESOURCE_LEAK)?

No runtime testing.

src/icmp/net_db.cc
src/icmp/net_db.h

index 44184af59182dd60a29cd32a4081661179127b21..2c27304388e9e0ab5c9b5972bdcac016a10c285a 100644 (file)
@@ -120,9 +120,9 @@ static void
 netdbHashInsert(netdbEntry * n, Ip::Address &addr)
 {
     networkFromInaddr(addr).toStr(n->network, MAX_IPSTRLEN);
-    n->hash.key = n->network;
+    n->key = n->network;
     assert(hash_lookup(addr_table, n->network) == NULL);
-    hash_join(addr_table, &n->hash);
+    hash_join(addr_table, n);
 }
 
 static void
@@ -142,7 +142,7 @@ net_db_name::net_db_name(const char *hostname, netdbEntry *e) :
     next(e ? e->hosts : nullptr),
     net_db_entry(e)
 {
-    hash.key = xstrdup(hostname);
+    key = xstrdup(hostname);
     if (e) {
         e->hosts = this;
         ++ e->link_count;
@@ -154,7 +154,7 @@ netdbHostInsert(netdbEntry * n, const char *hostname)
 {
     net_db_name *x = new net_db_name(hostname, n);
     assert(hash_lookup(host_table, hostname) == NULL);
-    hash_join(host_table, &x->hash);
+    hash_join(host_table, x);
 }
 
 static void
@@ -513,7 +513,7 @@ netdbSaveState(void *foo)
                       (int) n->last_use_time);
 
         for (x = n->hosts; x; x = x->next)
-            logfilePrintf(lf, " %s", hashKeyStr(&x->hash));
+            logfilePrintf(lf, " %s", hashKeyStr(x));
 
         logfilePrintf(lf, "\n");
 
@@ -1011,7 +1011,7 @@ netdbDump(StoreEntry * sentry)
                           n->hops);
 
         for (x = n->hosts; x; x = x->next)
-            storeAppendPrintf(sentry, " %s", hashKeyStr(&x->hash));
+            storeAppendPrintf(sentry, " %s", hashKeyStr(x));
 
         storeAppendPrintf(sentry, "\n");
 
index 0bfd5b2b9feda788553a25e53b61939f0eba2405..1a8cf24224931caaf353c4493d9b424fb798acd7 100644 (file)
@@ -19,15 +19,15 @@ class netdbEntry;
 class StoreEntry;
 class URL;
 
-class net_db_name
+class net_db_name:
+    public hash_link /* must be first */
 {
     MEMPROXY_CLASS(net_db_name);
 
 public:
     net_db_name(const char *name, netdbEntry *);
-    ~net_db_name() {xfree(hash.key);}
+    ~net_db_name() { xfree(key); }
 
-    hash_link hash;     /* must be first */
     net_db_name *next;
     netdbEntry *net_db_entry;
 };
@@ -42,14 +42,14 @@ public:
     time_t expires;
 };
 
-class netdbEntry
+class netdbEntry:
+    public hash_link /* must be first */
 {
     MEMPROXY_CLASS(netdbEntry);
 
 public:
     netdbEntry() { *network = 0; }
 
-    hash_link hash;     /* must be first */
     char network[MAX_IPSTRLEN];
     int pings_sent = 0;
     int pings_recv = 0;