zwoop commented on issue #7151:
URL: https://github.com/apache/trafficserver/issues/7151#issuecomment-687895430
@thelounge-zz Can you test the following patch, and see if it gets rid of
that odd warning in ControlMatcher?
```
diff --git a/include/tscore/HostLookup.h b/include/tscore/HostLookup.h
index e5135d8b5..124e04fae 100644
--- a/include/tscore/HostLookup.h
+++ b/include/tscore/HostLookup.h
@@ -124,7 +124,7 @@ public:
HostLookup(std::string_view name);
void NewEntry(std::string_view match_data, bool domain_record, void
*opaque_data_in);
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
bool Match(std::string_view host);
bool Match(std::string_view host, void **opaque_ptr);
bool MatchFirst(std::string_view host, HostLookupState *s, void
**opaque_ptr);
diff --git a/iocore/cache/CacheHosting.cc b/iocore/cache/CacheHosting.cc
index 41c995742..63c62c954 100644
--- a/iocore/cache/CacheHosting.cc
+++ b/iocore/cache/CacheHosting.cc
@@ -72,12 +72,12 @@ CacheHostMatcher::PrintFunc(void *opaque_data)
d->Print();
}
-// void CacheHostMatcher::AllocateSpace(int num_entries)
+// void CacheHostMatcher::AllocateSpace(size_t num_entries)
//
// Allocates the the HostLeaf and Data arrays
//
void
-CacheHostMatcher::AllocateSpace(int num_entries)
+CacheHostMatcher::AllocateSpace(size_t num_entries)
{
// Should not have been allocated before
ink_assert(array_len == -1);
diff --git a/iocore/cache/P_CacheHosting.h b/iocore/cache/P_CacheHosting.h
index e6eaa764e..52072818a 100644
--- a/iocore/cache/P_CacheHosting.h
+++ b/iocore/cache/P_CacheHosting.h
@@ -74,7 +74,7 @@ public:
CacheHostMatcher(const char *name, CacheType typ);
~CacheHostMatcher();
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
void NewEntry(matcher_line *line_info);
void Match(const char *rdata, int rlen, CacheHostResult *result) const;
diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc
index 3b51cb57d..83c19d2d5 100644
--- a/proxy/ControlMatcher.cc
+++ b/proxy/ControlMatcher.cc
@@ -125,13 +125,13 @@ HostMatcher<Data, MatchResult>::PrintFunc(void
*opaque_data)
d->Print();
}
-// void HostMatcher<Data,MatchResult>::AllocateSpace(int num_entries)
+// void HostMatcher<Data,MatchResult>::AllocateSpace(size_t num_entries)
//
// Allocates the the HostLeaf and Data arrays
//
template <class Data, class MatchResult>
void
-HostMatcher<Data, MatchResult>::AllocateSpace(int num_entries)
+HostMatcher<Data, MatchResult>::AllocateSpace(size_t num_entries)
{
// Should not have been allocated before
ink_assert(array_len == -1);
@@ -266,14 +266,15 @@ UrlMatcher<Data, MatchResult>::Print() const
}
//
-// void UrlMatcher<Data,MatchResult>::AllocateSpace(int num_entries)
+// void UrlMatcher<Data,MatchResult>::AllocateSpace(size_t num_entries)
//
template <class Data, class MatchResult>
void
-UrlMatcher<Data, MatchResult>::AllocateSpace(int num_entries)
+UrlMatcher<Data, MatchResult>::AllocateSpace(size_t num_entries)
{
// Should not have been allocated before
ink_assert(array_len == -1);
+ ink_release_assert(num_entries < UINT_MAX);
data_array = new Data[num_entries];
url_value = new int[num_entries];
@@ -399,11 +400,11 @@ RegexMatcher<Data, MatchResult>::Print() const
}
//
-// void RegexMatcher<Data,MatchResult>::AllocateSpace(int num_entries)
+// void RegexMatcher<Data,MatchResult>::AllocateSpace(size_t num_entries)
//
template <class Data, class MatchResult>
void
-RegexMatcher<Data, MatchResult>::AllocateSpace(int num_entries)
+RegexMatcher<Data, MatchResult>::AllocateSpace(size_t num_entries)
{
// Should not have been allocated before
ink_assert(array_len == -1);
@@ -575,11 +576,11 @@ IpMatcher<Data, MatchResult>::IpMatcher(const char
*name, const char *filename)
}
//
-// void IpMatcher<Data,MatchResult>::AllocateSpace(int num_entries)
+// void IpMatcher<Data,MatchResult>::AllocateSpace(size_t num_entries)
//
template <class Data, class MatchResult>
void
-IpMatcher<Data, MatchResult>::AllocateSpace(int num_entries)
+IpMatcher<Data, MatchResult>::AllocateSpace(size_t num_entries)
{
// Should not have been allocated before
ink_assert(array_len == -1);
diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h
index 6c1a3cbda..70b89110d 100644
--- a/proxy/ControlMatcher.h
+++ b/proxy/ControlMatcher.h
@@ -184,7 +184,7 @@ public:
UrlMatcher(const char *name, const char *filename);
~UrlMatcher();
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
Result NewEntry(matcher_line *line_info);
void Match(RequestData *rdata, MatchResult *result) const;
@@ -210,7 +210,7 @@ public:
RegexMatcher(const char *name, const char *filename);
~RegexMatcher();
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
Result NewEntry(matcher_line *line_info);
void Match(RequestData *rdata, MatchResult *result) const;
@@ -250,7 +250,7 @@ public:
HostMatcher(const char *name, const char *filename);
~HostMatcher();
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
Result NewEntry(matcher_line *line_info);
void Match(RequestData *rdata, MatchResult *result) const;
@@ -280,7 +280,7 @@ template <class Data, class MatchResult> class IpMatcher
: protected BaseMatcher
public:
IpMatcher(const char *name, const char *filename);
- void AllocateSpace(int num_entries);
+ void AllocateSpace(size_t num_entries);
Result NewEntry(matcher_line *line_info);
void Match(sockaddr const *ip_addr, RequestData *rdata, MatchResult
*result) const;
diff --git a/src/tscore/HostLookup.cc b/src/tscore/HostLookup.cc
index b695e0f47..97e72925f 100644
--- a/src/tscore/HostLookup.cc
+++ b/src/tscore/HostLookup.cc
@@ -926,12 +926,12 @@ HostLookup::MatchNext(HostLookupState *s, void
**opaque_ptr)
return false;
}
-// void HostLookup::AllocateSpace(int num_entries)
+// void HostLookup::AllocateSpace(size_t num_entries)
//
// Allocate the leaf array structure
//
void
-HostLookup::AllocateSpace(int num_entries)
+HostLookup::AllocateSpace(size_t num_entries)
{
leaf_array.reserve(num_entries);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]