From: Joshua Rogers Date: Tue, 6 Apr 2021 14:01:02 +0000 (+0000) Subject: Fix various Clang-12.0 compiler warnings (#800) X-Git-Tag: 4.15-20210522-snapshot~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4bae09eecb8689eb70acc9a44cede85ee10b075;p=thirdparty%2Fsquid.git Fix various Clang-12.0 compiler warnings (#800) Fixes -Wrange-loop-construct, -Wmismatched-tags, and -Wshadow. --- diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index 8ac7e6c810..0e85b9768b 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -595,7 +595,7 @@ ACLDestinationASNStrategy::match (ACLData * &data, ACLFilledChecklist const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->url.host(), IP_LOOKUP_IF_MISS); if (ia) { - for (const auto ip: ia->goodAndBad()) { + for (const auto &ip: ia->goodAndBad()) { if (data->match(ip)) return 1; } diff --git a/src/acl/DestinationIp.cc b/src/acl/DestinationIp.cc index 4347b93a58..a01c14129a 100644 --- a/src/acl/DestinationIp.cc +++ b/src/acl/DestinationIp.cc @@ -67,7 +67,7 @@ ACLDestinationIP::match(ACLChecklist *cl) if (ia) { /* Entry in cache found */ - for (const auto ip: ia->goodAndBad()) { + for (const auto &ip: ia->goodAndBad()) { if (ACLIP::match(ip)) return 1; } diff --git a/src/fs/rock/RockRebuild.cc b/src/fs/rock/RockRebuild.cc index 2d41da3d0a..3fac88be8a 100644 --- a/src/fs/rock/RockRebuild.cc +++ b/src/fs/rock/RockRebuild.cc @@ -258,16 +258,16 @@ Rock::Rebuild::Stats::Init(const SwapDir &dir) } bool -Rock::Rebuild::Stats::completed(const SwapDir &sd) const +Rock::Rebuild::Stats::completed(const SwapDir &dir) const { - return DoneLoading(counts.scancount, sd.slotLimitActual()) && - DoneValidating(counts.validations, sd.slotLimitActual(), sd.entryLimitActual()); + return DoneLoading(counts.scancount, dir.slotLimitActual()) && + DoneValidating(counts.validations, dir.slotLimitActual(), dir.entryLimitActual()); } /* Rebuild */ bool -Rock::Rebuild::IsResponsible(const SwapDir &sd) +Rock::Rebuild::IsResponsible(const SwapDir &dir) { // in SMP mode, only the disker is responsible for populating the map return !UsingSmp() || IamDiskProcess(); diff --git a/src/http/RegisteredHeadersHash.cci b/src/http/RegisteredHeadersHash.cci index aee8c808b8..59968f1c27 100644 --- a/src/http/RegisteredHeadersHash.cci +++ b/src/http/RegisteredHeadersHash.cci @@ -41,8 +41,8 @@ * Please see the COPYING and CONTRIBUTORS files for details. */ #line 24 "RegisteredHeadersHash.gperf" -struct HeaderTableRecord; - enum +class HeaderTableRecord; + enum { TOTAL_KEYWORDS = 88, MIN_WORD_LENGTH = 2, @@ -103,7 +103,7 @@ class HttpHeaderHashTable private: static inline unsigned int HttpHeaderHash (const char *str, size_t len); public: - static const struct HeaderTableRecord *lookup (const char *str, size_t len); + static const class HeaderTableRecord *lookup (const char *str, size_t len); }; inline unsigned int @@ -171,7 +171,7 @@ static const unsigned char lengthtable[] = 19, 0, 0, 0, 18, 14, 0, 0, 13, 13, 0, 13 }; -static const struct HeaderTableRecord HttpHeaderDefinitionsTable[] = +static const class HeaderTableRecord HttpHeaderDefinitionsTable[] = { {""}, {""}, {""}, {""}, {""}, #line 67 "RegisteredHeadersHash.gperf" @@ -363,7 +363,7 @@ static const struct HeaderTableRecord HttpHeaderDefinitionsTable[] = {"Last-Modified", Http::HdrType::LAST_MODIFIED, Http::HdrFieldType::ftDate_1123, HdrKind::EntityHeader} }; -const struct HeaderTableRecord * +const class HeaderTableRecord * HttpHeaderHashTable::lookup (const char *str, size_t len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) diff --git a/src/http/RegisteredHeadersHash.gperf b/src/http/RegisteredHeadersHash.gperf index 1f70c2e008..a406fe57db 100644 --- a/src/http/RegisteredHeadersHash.gperf +++ b/src/http/RegisteredHeadersHash.gperf @@ -21,7 +21,7 @@ %global-table %ignore-case %struct-type -struct HeaderTableRecord; +class HeaderTableRecord; %% Accept, Http::HdrType::ACCEPT, Http::HdrFieldType::ftStr, HdrKind::ListHeader|HdrKind::RequestHeader Accept-Charset, Http::HdrType::ACCEPT_CHARSET, Http::HdrFieldType::ftStr, HdrKind::ListHeader|HdrKind::RequestHeader diff --git a/src/multicast.cc b/src/multicast.cc index cbd48f7cb3..a3a848dcd9 100644 --- a/src/multicast.cc +++ b/src/multicast.cc @@ -42,7 +42,7 @@ mcastJoinGroups(const ipcache_addrs *ia, const Dns::LookupDetails &, void *) return; } - for (const auto ip: ia->goodAndBad()) { // TODO: Consider using just good(). + for (const auto &ip: ia->goodAndBad()) { // TODO: Consider using just good(). debugs(7, 9, "Listening for ICP requests on " << ip); if (!ip.isIPv4()) {