From: Alex Rousskov Date: Sat, 22 Jul 2017 03:47:06 +0000 (-0600) Subject: Cleaned up net_db structures. Made Coverity happier? (#27) X-Git-Tag: M-staged-PR71~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ec218d55249c6edd2a4fe4511212a721c98394b;p=thirdparty%2Fsquid.git Cleaned up net_db structures. Made Coverity happier? (#27) Fixes false positive by Coverity Scan. Issue 1415048 (RESOURCE_LEAK)? No runtime testing. --- diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 44184af591..2c27304388 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -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"); diff --git a/src/icmp/net_db.h b/src/icmp/net_db.h index 0bfd5b2b9f..1a8cf24224 100644 --- a/src/icmp/net_db.h +++ b/src/icmp/net_db.h @@ -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;