From 0c1515c2574f9308d36bcfe97b826fd43979eb0a Mon Sep 17 00:00:00 2001 From: Randall Meyer Date: Thu, 30 Jul 2020 12:55:39 -0700 Subject: [PATCH] constify Print() methods and other low hanging fruit --- include/tscore/HostLookup.h | 9 ++++-- include/tscore/Tokenizer.h | 2 +- include/tscore/Trie.h | 5 ++-- iocore/cache/CacheHosting.cc | 12 ++++---- iocore/cache/P_CacheHosting.h | 15 ++++++---- iocore/dns/P_SplitDNSProcessor.h | 2 +- iocore/dns/SplitDNS.cc | 2 +- proxy/CacheControl.cc | 4 +-- proxy/CacheControl.h | 4 +-- proxy/ControlBase.cc | 4 +-- proxy/ControlBase.h | 5 +++- proxy/ControlMatcher.cc | 26 ++++++++--------- proxy/ControlMatcher.h | 37 ++++++++++++++--------- proxy/IPAllow.cc | 4 +-- proxy/IPAllow.h | 5 ++-- proxy/ParentSelection.cc | 6 +--- proxy/ParentSelection.h | 4 ++- proxy/hdrs/URL.h | 39 +++++++++++++------------ proxy/http/remap/UrlMapping.cc | 2 +- proxy/http/remap/UrlMapping.h | 2 +- proxy/http/remap/UrlMappingPathIndex.cc | 3 +- proxy/http/remap/UrlMappingPathIndex.h | 2 +- proxy/http/remap/UrlRewrite.cc | 4 +-- proxy/http/remap/UrlRewrite.h | 4 +-- src/tscore/HostLookup.cc | 6 ++-- src/tscore/Tokenizer.cc | 9 +++--- 26 files changed, 120 insertions(+), 97 deletions(-) diff --git a/include/tscore/HostLookup.h b/include/tscore/HostLookup.h index 1d5bdb7302e..e5135d8b520 100644 --- a/include/tscore/HostLookup.h +++ b/include/tscore/HostLookup.h @@ -129,8 +129,9 @@ class HostLookup bool Match(std::string_view host, void **opaque_ptr); bool MatchFirst(std::string_view host, HostLookupState *s, void **opaque_ptr); bool MatchNext(HostLookupState *s, void **opaque_ptr); - void Print(PrintFunc const &f); - void Print(); + + void Print(PrintFunc const &f) const; + void Print() const; LeafArray * get_leaf_array() @@ -147,7 +148,9 @@ class HostLookup HostBranch *InsertBranch(HostBranch *insert_in, std::string_view level_data); HostBranch *FindNextLevel(HostBranch *from, std::string_view level_data, bool bNotProcess = false); bool MatchArray(HostLookupState *s, void **opaque_ptr, LeafIndices &array, bool host_done); - void PrintHostBranch(HostBranch *hb, PrintFunc const &f); + + void PrintHostBranch(const HostBranch *hb, PrintFunc const &f) const; + HostBranch root; // The top of the search tree LeafArray leaf_array; // array of all leaves in tree std::string matcher_name; // Used for Debug/Warning/Error messages diff --git a/include/tscore/Tokenizer.h b/include/tscore/Tokenizer.h index a86c96abc0a..c073d45c745 100644 --- a/include/tscore/Tokenizer.h +++ b/include/tscore/Tokenizer.h @@ -143,7 +143,7 @@ class Tokenizer }; unsigned count() const; - void Print(); // Debugging print out + void Print() const; inkcoreapi const char *iterFirst(tok_iter_state *state); inkcoreapi const char *iterNext(tok_iter_state *state); diff --git a/include/tscore/Trie.h b/include/tscore/Trie.h index bf31a1a45da..67f5d938f42 100644 --- a/include/tscore/Trie.h +++ b/include/tscore/Trie.h @@ -20,6 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ + #pragma once #include @@ -42,7 +43,7 @@ template class Trie // will return false if not found; else value_ptr will point to found value T *Search(const char *key, int key_len = -1) const; void Clear(); - void Print(); + void Print() const; bool Empty() const @@ -229,7 +230,7 @@ Trie::Clear() template void -Trie::Print() +Trie::Print() const { // The class we contain must provide a ::Print() method. forl_LL(T, iter, m_value_list) iter->Print(); diff --git a/iocore/cache/CacheHosting.cc b/iocore/cache/CacheHosting.cc index f8080bce52b..41c995742ff 100644 --- a/iocore/cache/CacheHosting.cc +++ b/iocore/cache/CacheHosting.cc @@ -53,7 +53,7 @@ CacheHostMatcher::~CacheHostMatcher() // Debugging Method // void -CacheHostMatcher::Print() +CacheHostMatcher::Print() const { printf("\tHost/Domain Matcher with %d elements\n", num_el); host_lookup->Print(PrintFunc); @@ -96,7 +96,7 @@ CacheHostMatcher::AllocateSpace(int num_entries) // arg hostname // void -CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result) +CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result) const { void *opaque_ptr; CacheHostRecord *data_ptr; @@ -111,6 +111,7 @@ CacheHostMatcher::Match(const char *rdata, int rlen, CacheHostResult *result) if (rlen == 0) { return; } + char *data = static_cast(ats_malloc(rlen + 1)); memcpy(data, rdata, rlen); *(data + rlen) = '\0'; @@ -208,7 +209,7 @@ CacheHostTable::~CacheHostTable() // Debugging method // void -CacheHostTable::Print() +CacheHostTable::Print() const { printf("Control Matcher Table: %s\n", matcher_name); if (hostMatch != nullptr) { @@ -222,7 +223,7 @@ CacheHostTable::Print() // Queries each table for the Result* // void -CacheHostTable::Match(const char *rdata, int rlen, CacheHostResult *result) +CacheHostTable::Match(const char *rdata, int rlen, CacheHostResult *result) const { hostMatch->Match(rdata, rlen, result); } @@ -272,6 +273,7 @@ CacheHostTable::BuildTableFromString(const char *config_file_path, char *file_bu } return 0; } + // First get the number of entries tmp = bufTok.iterFirst(&i_state); while (tmp != nullptr) { @@ -587,7 +589,7 @@ CacheHostRecord::UpdateMatch(CacheHostResult *r, char * /* rd ATS_UNUSED */) } void -CacheHostRecord::Print() +CacheHostRecord::Print() const { } diff --git a/iocore/cache/P_CacheHosting.h b/iocore/cache/P_CacheHosting.h index ba4af9b20a1..e6eaa764edf 100644 --- a/iocore/cache/P_CacheHosting.h +++ b/iocore/cache/P_CacheHosting.h @@ -37,8 +37,10 @@ struct Cache; struct CacheHostRecord { int Init(CacheType typ); int Init(matcher_line *line_info, CacheType typ); + void UpdateMatch(CacheHostResult *r, char *rd); - void Print(); + void Print() const; + ~CacheHostRecord() { ats_free(vols); @@ -72,10 +74,11 @@ class CacheHostMatcher CacheHostMatcher(const char *name, CacheType typ); ~CacheHostMatcher(); - void Match(const char *rdata, int rlen, CacheHostResult *result); void AllocateSpace(int num_entries); void NewEntry(matcher_line *line_info); - void Print(); + + void Match(const char *rdata, int rlen, CacheHostResult *result) const; + void Print() const; int getNumElements() const @@ -109,10 +112,12 @@ class CacheHostTable // object is CacheHostTable(Cache *c, CacheType typ); ~CacheHostTable(); + int BuildTable(const char *config_file_path); int BuildTableFromString(const char *config_file_path, char *str); - void Match(const char *rdata, int rlen, CacheHostResult *result); - void Print(); + + void Match(const char *rdata, int rlen, CacheHostResult *result) const; + void Print() const; int getEntryCount() const diff --git a/iocore/dns/P_SplitDNSProcessor.h b/iocore/dns/P_SplitDNSProcessor.h index 6f42a47b443..bb7c2fc2ab3 100644 --- a/iocore/dns/P_SplitDNSProcessor.h +++ b/iocore/dns/P_SplitDNSProcessor.h @@ -200,7 +200,7 @@ class SplitDNSRecord : public ControlBase const char *ProcessDefDomain(char *val); void UpdateMatch(SplitDNSResult *result, RequestData *rdata); - void Print(); + void Print() const; DNSServer m_servers; int m_dnsSrvr_cnt = 0; diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc index 28babca1fd2..8af72da9209 100644 --- a/iocore/dns/SplitDNS.cc +++ b/iocore/dns/SplitDNS.cc @@ -531,7 +531,7 @@ SplitDNSRecord::UpdateMatch(SplitDNSResult *result, RequestData * /* rdata ATS_U SplitDNSRecord::Print() -------------------------------------------------------------- */ void -SplitDNSRecord::Print() +SplitDNSRecord::Print() const { for (int i = 0; i < m_dnsSrvr_cnt; i++) { char ab[INET6_ADDRPORTSTRLEN]; diff --git a/proxy/CacheControl.cc b/proxy/CacheControl.cc index 5a0a229bc7c..91749f181ac 100644 --- a/proxy/CacheControl.cc +++ b/proxy/CacheControl.cc @@ -184,7 +184,7 @@ getCacheControl(CacheControlResult *result, HttpRequestData *rdata, const Overri // Debugging Method // void -CacheControlResult::Print() +CacheControlResult::Print() const { printf("\t reval: %d, never-cache: %d, pin: %d, ignore-c: %d ignore-s: %d\n", revalidate_after, never_cache, pin_in_cache_for, ignore_client_no_cache, ignore_server_no_cache); @@ -195,7 +195,7 @@ CacheControlResult::Print() // Debugging Method // void -CacheControlRecord::Print() +CacheControlRecord::Print() const { switch (this->directive) { case CC_REVALIDATE_AFTER: diff --git a/proxy/CacheControl.h b/proxy/CacheControl.h index e6730c6990a..f3395e38cea 100644 --- a/proxy/CacheControl.h +++ b/proxy/CacheControl.h @@ -63,7 +63,7 @@ class CacheControlResult { public: inkcoreapi CacheControlResult(); - void Print(); + void Print() const; // Data for external use // @@ -109,7 +109,7 @@ class CacheControlRecord : public ControlBase int cache_responses_to_cookies = -1; Result Init(matcher_line *line_info); inkcoreapi void UpdateMatch(CacheControlResult *result, RequestData *rdata); - void Print(); + void Print() const; }; inline CacheControlRecord::CacheControlRecord() : ControlBase() {} diff --git a/proxy/ControlBase.cc b/proxy/ControlBase.cc index be0d47f811e..36c8b938bcd 100644 --- a/proxy/ControlBase.cc +++ b/proxy/ControlBase.cc @@ -694,10 +694,8 @@ ControlBase::clear() _mods.clear(); } -// static const modifier_el default_el = { MOD_INVALID, NULL }; - void -ControlBase::Print() +ControlBase::Print() const { int n = _mods.size(); diff --git a/proxy/ControlBase.h b/proxy/ControlBase.h index 4c79d544865..8a6791c68aa 100644 --- a/proxy/ControlBase.h +++ b/proxy/ControlBase.h @@ -73,10 +73,13 @@ class ControlBase ControlBase(); ~ControlBase(); + const char *ProcessModifiers(matcher_line *line_info); bool CheckModifiers(HttpRequestData *request_data); bool CheckForMatch(HttpRequestData *request_data, int last_number); - void Print(); + + void Print() const; + int line_num = 0; Modifier *findModOfType(Modifier::Type t) const; diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc index 9695457d52c..ec946099d7f 100644 --- a/proxy/ControlMatcher.cc +++ b/proxy/ControlMatcher.cc @@ -105,7 +105,7 @@ template HostMatcher::~HostMa // template void -HostMatcher::Print() +HostMatcher::Print() const { printf("\tHost/Domain Matcher with %d elements\n", num_el); host_lookup->Print(PrintFunc); @@ -150,7 +150,7 @@ HostMatcher::AllocateSpace(int num_entries) // template void -HostMatcher::Match(RequestData *rdata, MatchResult *result) +HostMatcher::Match(RequestData *rdata, MatchResult *result) const { void *opaque_ptr; Data *data_ptr; @@ -256,7 +256,7 @@ template UrlMatcher::~UrlMatc // template void -UrlMatcher::Print() +UrlMatcher::Print() const { printf("\tUrl Matcher with %d elements\n", num_el); for (int i = 0; i < num_el; i++) { @@ -335,7 +335,7 @@ UrlMatcher::NewEntry(matcher_line *line_info) // template void -UrlMatcher::Match(RequestData *rdata, MatchResult *result) +UrlMatcher::Match(RequestData *rdata, MatchResult *result) const { char *url_str; @@ -383,13 +383,13 @@ template RegexMatcher::~Regex } // -// void RegexMatcher::Print() +// void RegexMatcher::Print() const // // Debugging function // template void -RegexMatcher::Print() +RegexMatcher::Print() const { printf("\tRegex Matcher with %d elements\n", num_el); for (int i = 0; i < num_el; i++) { @@ -482,7 +482,7 @@ RegexMatcher::NewEntry(matcher_line *line_info) // template void -RegexMatcher::Match(RequestData *rdata, MatchResult *result) +RegexMatcher::Match(RequestData *rdata, MatchResult *result) const { char *url_str; int r; @@ -535,7 +535,7 @@ HostRegexMatcher::HostRegexMatcher(const char *name, const ch // template void -HostRegexMatcher::Match(RequestData *rdata, MatchResult *result) +HostRegexMatcher::Match(RequestData *rdata, MatchResult *result) const { const char *url_str; int r; @@ -649,7 +649,7 @@ IpMatcher::NewEntry(matcher_line *line_info) // template void -IpMatcher::Match(sockaddr const *addr, RequestData *rdata, MatchResult *result) +IpMatcher::Match(sockaddr const *addr, RequestData *rdata, MatchResult *result) const { void *raw; if (ip_map.contains(addr, &raw)) { @@ -661,7 +661,7 @@ IpMatcher::Match(sockaddr const *addr, RequestData *rdata, Ma template void -IpMatcher::Print() +IpMatcher::Print() const { printf("\tIp Matcher with %d elements, %zu ranges.\n", num_el, ip_map.count()); for (IpMap::iterator spot(ip_map.begin()), limit(ip_map.end()); spot != limit; ++spot) { @@ -718,7 +718,7 @@ template ControlMatcher::~Con // template void -ControlMatcher::Print() +ControlMatcher::Print() const { printf("Control Matcher Table: %s\n", matcher_name); if (hostMatch != nullptr) { @@ -739,13 +739,13 @@ ControlMatcher::Print() } // void ControlMatcher::Match(RequestData* rdata -// MatchResult* result) +// MatchResult* result) const // // Queries each table for the MatchResult* // template void -ControlMatcher::Match(RequestData *rdata, MatchResult *result) +ControlMatcher::Match(RequestData *rdata, MatchResult *result) const { if (hostMatch != nullptr) { hostMatch->Match(rdata, result); diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h index 50cb2916e6e..145e958e4f9 100644 --- a/proxy/ControlMatcher.h +++ b/proxy/ControlMatcher.h @@ -183,10 +183,12 @@ template class UrlMatcher : protected BaseMatche public: UrlMatcher(const char *name, const char *filename); ~UrlMatcher(); - void Match(RequestData *rdata, MatchResult *result); + void AllocateSpace(int num_entries); Result NewEntry(matcher_line *line_info); - void Print(); + + void Match(RequestData *rdata, MatchResult *result) const; + void Print() const; using super::num_el; using super::matcher_name; @@ -207,10 +209,12 @@ template class RegexMatcher : protected BaseMatc public: RegexMatcher(const char *name, const char *filename); ~RegexMatcher(); - void Match(RequestData *rdata, MatchResult *result); + void AllocateSpace(int num_entries); Result NewEntry(matcher_line *line_info); - void Print(); + + void Match(RequestData *rdata, MatchResult *result) const; + void Print() const; using super::num_el; using super::matcher_name; @@ -229,7 +233,7 @@ template class HostRegexMatcher : public RegexMa public: HostRegexMatcher(const char *name, const char *filename); - void Match(RequestData *rdata, MatchResult *result); + void Match(RequestData *rdata, MatchResult *result) const; using super::num_el; using super::matcher_name; @@ -245,10 +249,12 @@ template class HostMatcher : protected BaseMatch public: HostMatcher(const char *name, const char *filename); ~HostMatcher(); - void Match(RequestData *rdata, MatchResult *result); + void AllocateSpace(int num_entries); Result NewEntry(matcher_line *line_info); - void Print(); + + void Match(RequestData *rdata, MatchResult *result) const; + void Print() const; using super::num_el; using super::matcher_name; @@ -273,10 +279,12 @@ template class IpMatcher : protected BaseMatcher public: IpMatcher(const char *name, const char *filename); - void Match(sockaddr const *ip_addr, RequestData *rdata, MatchResult *result); + void AllocateSpace(int num_entries); Result NewEntry(matcher_line *line_info); - void Print(); + + void Match(sockaddr const *ip_addr, RequestData *rdata, MatchResult *result) const; + void Print() const; using super::num_el; using super::matcher_name; @@ -299,18 +307,19 @@ template class IpMatcher : protected BaseMatcher template class ControlMatcher { public: - // Parameter name must not be deallocated before this - // object is + // Parameter name must not be deallocated before this object is ControlMatcher(const char *file_var, const char *name, const matcher_tags *tags, int flags_in = (ALLOW_HOST_TABLE | ALLOW_IP_TABLE | ALLOW_REGEX_TABLE | ALLOW_HOST_REGEX_TABLE | ALLOW_URL_TABLE)); ~ControlMatcher(); + int BuildTable(); int BuildTableFromString(char *str); - void Match(RequestData *rdata, MatchResult *result); - void Print(); + + void Match(RequestData *rdata, MatchResult *result) const; + void Print() const; int - getEntryCount() + getEntryCount() const { return m_numEntries; } diff --git a/proxy/IPAllow.cc b/proxy/IPAllow.cc index 776c8b5fd34..655c2516aed 100644 --- a/proxy/IPAllow.cc +++ b/proxy/IPAllow.cc @@ -196,7 +196,7 @@ IpAllow::match(sockaddr const *ip, match_key_t key) IpAllow::IpAllow(const char *config_var) : config_file(ats_scoped_str(RecConfigReadConfigPath(config_var)).get()) {} void -IpAllow::PrintMap(IpMap *map) +IpAllow::PrintMap(const IpMap *map) const { std::ostringstream s; s << map->count() << " ACL entries."; @@ -243,7 +243,7 @@ IpAllow::PrintMap(IpMap *map) } void -IpAllow::Print() +IpAllow::Print() const { Debug("ip-allow", "Printing src map"); PrintMap(&_src_map); diff --git a/proxy/IPAllow.h b/proxy/IPAllow.h index 5656a5c694f..9221e7525bd 100644 --- a/proxy/IPAllow.h +++ b/proxy/IPAllow.h @@ -147,7 +147,7 @@ class IpAllow : public ConfigInfo explicit IpAllow(const char *config_var); - void Print(); + void Print() const; static ACL match(sockaddr const *ip, match_key_t key); static ACL match(IpEndpoint const *ip, match_key_t key); @@ -187,7 +187,8 @@ class IpAllow : public ConfigInfo static const Record ALLOW_ALL_RECORD; ///< Static record that allows all access. static bool accept_check_p; ///< @c true if deny all can be enforced during accept. - void PrintMap(IpMap *map); + void PrintMap(const IpMap *map) const; + int BuildTable(); int ATSBuildTable(const std::string &); int YAMLBuildTable(const std::string &); diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc index ec2d144b1cd..08254a453d8 100644 --- a/proxy/ParentSelection.cc +++ b/proxy/ParentSelection.cc @@ -300,10 +300,6 @@ ParentConfig::reconfigure() Note("%s finished loading", ts::filename::PARENT); } -// void ParentConfig::print -// -// Debugging function -// void ParentConfig::print() { @@ -862,7 +858,7 @@ ParentRecord::~ParentRecord() } void -ParentRecord::Print() +ParentRecord::Print() const { printf("\t\t"); for (int i = 0; i < num_parents; i++) { diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h index 1e4648560ce..d9cf6e80942 100644 --- a/proxy/ParentSelection.h +++ b/proxy/ParentSelection.h @@ -136,7 +136,9 @@ class ParentRecord : public ControlBase Result Init(matcher_line *line_info); bool DefaultInit(char *val); void UpdateMatch(ParentResult *result, RequestData *rdata); - void Print(); + + void Print() const; + pRecord *parents = nullptr; pRecord *secondary_parents = nullptr; int num_parents = 0; diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h index 025d2dbabb8..36f52aa184d 100644 --- a/proxy/hdrs/URL.h +++ b/proxy/hdrs/URL.h @@ -238,19 +238,21 @@ class URL : public HdrHeapSDKHandle // Note that URL::destroy() is inherited from HdrHeapSDKHandle. void nuke_proxy_stuff(); - int print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized = false); + int print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized = false) const; + + int length_get() const; - int length_get(); void clear_string_ref(); - char *string_get(Arena *arena, int *length = nullptr, bool normalized = false); - char *string_get_ref(int *length = nullptr, bool normalized = false); - char *string_get_buf(char *dstbuf, int dsbuf_size, int *length = nullptr); + + char *string_get(Arena *arena, int *length = nullptr, bool normalized = false) const; + char *string_get_ref(int *length = nullptr, bool normalized = false) const; + char *string_get_buf(char *dstbuf, int dsbuf_size, int *length = nullptr) const; void hash_get(CryptoHash *hash, cache_generation_t generation = -1) const; - void host_hash_get(CryptoHash *hash); + void host_hash_get(CryptoHash *hash) const; const char *scheme_get(int *length); const std::string_view scheme_get(); - int scheme_get_wksidx(); + int scheme_get_wksidx() const; void scheme_set(const char *value, int length); const char *user_get(int *length); @@ -259,8 +261,9 @@ class URL : public HdrHeapSDKHandle void password_set(const char *value, int length); const char *host_get(int *length); void host_set(const char *value, int length); - int port_get(); - int port_get_raw(); + + int port_get() const; + int port_get_raw() const; void port_set(int port); const char *path_get(int *length); @@ -372,7 +375,7 @@ URL::nuke_proxy_stuff() -------------------------------------------------------------------------*/ inline int -URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized) +URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normalized) const { ink_assert(valid()); return url_print(m_url_impl, buf, bufsize, bufindex, dumpoffset, normalized); @@ -382,7 +385,7 @@ URL::print(char *buf, int bufsize, int *bufindex, int *dumpoffset, bool normaliz -------------------------------------------------------------------------*/ inline int -URL::length_get() +URL::length_get() const { ink_assert(valid()); return url_length_get(m_url_impl); @@ -392,14 +395,14 @@ URL::length_get() -------------------------------------------------------------------------*/ inline char * -URL::string_get(Arena *arena_or_null_for_malloc, int *length, bool normalized) +URL::string_get(Arena *arena_or_null_for_malloc, int *length, bool normalized) const { ink_assert(valid()); return url_string_get(m_url_impl, arena_or_null_for_malloc, length, m_heap, normalized); } inline char * -URL::string_get_ref(int *length, bool normalized) +URL::string_get_ref(int *length, bool normalized) const { ink_assert(valid()); return url_string_get_ref(m_heap, m_url_impl, length, normalized); @@ -416,7 +419,7 @@ URL::clear_string_ref() /*------------------------------------------------------------------------- -------------------------------------------------------------------------*/ inline char * -URL::string_get_buf(char *dstbuf, int dsbuf_size, int *length) +URL::string_get_buf(char *dstbuf, int dsbuf_size, int *length) const { ink_assert(valid()); return url_string_get_buf(m_url_impl, dstbuf, dsbuf_size, length); @@ -436,7 +439,7 @@ URL::hash_get(CryptoHash *hash, cache_generation_t generation) const -------------------------------------------------------------------------*/ inline void -URL::host_hash_get(CryptoHash *hash) +URL::host_hash_get(CryptoHash *hash) const { ink_assert(valid()); url_host_CryptoHash_get(m_url_impl, hash); @@ -467,7 +470,7 @@ URL::scheme_get(int *length) } inline int -URL::scheme_get_wksidx() +URL::scheme_get_wksidx() const { ink_assert(valid()); return (m_url_impl->m_scheme_wks_idx); @@ -551,7 +554,7 @@ URL::host_set(const char *value, int length) -------------------------------------------------------------------------*/ inline int -URL::port_get() +URL::port_get() const { ink_assert(valid()); return url_canonicalize_port(m_url_impl->m_url_type, m_url_impl->m_port); @@ -561,7 +564,7 @@ URL::port_get() -------------------------------------------------------------------------*/ inline int -URL::port_get_raw() +URL::port_get_raw() const { ink_assert(valid()); return m_url_impl->m_port; diff --git a/proxy/http/remap/UrlMapping.cc b/proxy/http/remap/UrlMapping.cc index d592cef6118..4f1494b0729 100644 --- a/proxy/http/remap/UrlMapping.cc +++ b/proxy/http/remap/UrlMapping.cc @@ -84,7 +84,7 @@ url_mapping::~url_mapping() } void -url_mapping::Print() +url_mapping::Print() const { char from_url_buf[131072], to_url_buf[131072]; diff --git a/proxy/http/remap/UrlMapping.h b/proxy/http/remap/UrlMapping.h index 2fa52bed765..a0482c14c2f 100644 --- a/proxy/http/remap/UrlMapping.h +++ b/proxy/http/remap/UrlMapping.h @@ -92,7 +92,7 @@ class url_mapping return _plugin_inst_list.size(); } - void Print(); + void Print() const; int from_path_len = 0; URL fromURL; diff --git a/proxy/http/remap/UrlMappingPathIndex.cc b/proxy/http/remap/UrlMappingPathIndex.cc index f7b502142c8..95a47ed66a6 100644 --- a/proxy/http/remap/UrlMappingPathIndex.cc +++ b/proxy/http/remap/UrlMappingPathIndex.cc @@ -20,6 +20,7 @@ See the License for the specific language governing permissions and limitations under the License. */ + #include "UrlMappingPathIndex.h" UrlMappingPathIndex::~UrlMappingPathIndex() @@ -84,7 +85,7 @@ UrlMappingPathIndex::Search(URL *request_url, int request_port, bool normal_sear } void -UrlMappingPathIndex::Print() +UrlMappingPathIndex::Print() const { for (auto &m_trie : m_tries) { m_trie.second->Print(); diff --git a/proxy/http/remap/UrlMappingPathIndex.h b/proxy/http/remap/UrlMappingPathIndex.h index 290690d8f8b..6e4febc3243 100644 --- a/proxy/http/remap/UrlMappingPathIndex.h +++ b/proxy/http/remap/UrlMappingPathIndex.h @@ -37,7 +37,7 @@ class UrlMappingPathIndex virtual ~UrlMappingPathIndex(); bool Insert(url_mapping *mapping); url_mapping *Search(URL *request_url, int request_port, bool normal_search = true) const; - void Print(); + void Print() const; private: typedef Trie UrlMappingTrie; diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc index aab1b215398..17249434a68 100644 --- a/proxy/http/remap/UrlRewrite.cc +++ b/proxy/http/remap/UrlRewrite.cc @@ -140,7 +140,7 @@ UrlRewrite::_destroyTable(std::unique_ptr &h_table) /** Debugging Method. */ void -UrlRewrite::Print() +UrlRewrite::Print() const { printf("URL Rewrite table with %d entries\n", num_rules_forward + num_rules_reverse + num_rules_redirect_temporary + num_rules_redirect_permanent + num_rules_forward_with_recv_port); @@ -168,7 +168,7 @@ UrlRewrite::Print() /** Debugging method. */ void -UrlRewrite::PrintStore(MappingsStore &store) +UrlRewrite::PrintStore(const MappingsStore &store) const { if (store.hash_lookup) { for (auto &it : *store.hash_lookup) { diff --git a/proxy/http/remap/UrlRewrite.h b/proxy/http/remap/UrlRewrite.h index 7419edd9a09..8567857c48f 100644 --- a/proxy/http/remap/UrlRewrite.h +++ b/proxy/http/remap/UrlRewrite.h @@ -81,7 +81,7 @@ class UrlRewrite : public RefCountObj mapping_type Remap_redirect(HTTPHdr *request_header, URL *redirect_url); bool ReverseMap(HTTPHdr *response_header); void SetReverseFlag(int flag); - void Print(); + void Print() const; // The UrlRewrite object is-a RefCountObj, but this is a convenience to make it clear that we // don't delete() these objects directly, but via the release() method only. @@ -145,7 +145,7 @@ class UrlRewrite : public RefCountObj }; void PerformACLFiltering(HttpTransact::State *s, url_mapping *mapping); - void PrintStore(MappingsStore &store); + void PrintStore(const MappingsStore &store) const; void DestroyStore(MappingsStore &store) diff --git a/src/tscore/HostLookup.cc b/src/tscore/HostLookup.cc index b70a45a3511..b695e0f47d1 100644 --- a/src/tscore/HostLookup.cc +++ b/src/tscore/HostLookup.cc @@ -587,13 +587,13 @@ HostBranch::~HostBranch() HostLookup::HostLookup(string_view name) : matcher_name(name) {} void -HostLookup::Print() +HostLookup::Print() const { Print([](void *) -> void {}); } void -HostLookup::Print(PrintFunc const &f) +HostLookup::Print(PrintFunc const &f) const { PrintHostBranch(&root, f); } @@ -605,7 +605,7 @@ HostLookup::Print(PrintFunc const &f) // and print out each element // void -HostLookup::PrintHostBranch(HostBranch *hb, PrintFunc const &f) +HostLookup::PrintHostBranch(const HostBranch *hb, PrintFunc const &f) const { for (auto curIndex : hb->leaf_indices) { auto &leaf{leaf_array[curIndex]}; diff --git a/src/tscore/Tokenizer.cc b/src/tscore/Tokenizer.cc index 7db00078311..180095255b7 100644 --- a/src/tscore/Tokenizer.cc +++ b/src/tscore/Tokenizer.cc @@ -21,7 +21,6 @@ limitations under the License. */ -/***************************************/ #include "tscore/ink_platform.h" #include "tscore/Tokenizer.h" #include "tscore/ink_assert.h" @@ -334,11 +333,11 @@ Tokenizer::iterNext(tok_iter_state *state) } void -Tokenizer::Print() +Tokenizer::Print() const { - tok_node *cur_node = &start_node; - int node_index = 0; - int count = 0; + const tok_node *cur_node = &start_node; + int node_index = 0; + int count = 0; while (cur_node != nullptr) { if (cur_node->el[node_index] != nullptr) {