moonchen commented on code in PR #13352:
URL: https://github.com/apache/trafficserver/pull/13352#discussion_r3666973574
##########
plugins/prefetch/configs.cc:
##########
@@ -71,14 +71,39 @@ iequals(const StringView lhs, const StringView rhs)
[](const char a, const char b) { return tolower(a) ==
tolower(b); });
}
-void
+bool
PrefetchConfig::setFetchOverflow(const char *optarg)
{
- if (StringView("64") == optarg) {
+ if (nullptr == optarg) {
+ return false;
+ }
+ if (StringView("32") == optarg) {
+ _fetchOverflow = EvalPolicy::Overflow32;
+ } else if (StringView("64") == optarg) {
_fetchOverflow = EvalPolicy::Overflow64;
} else if (iequals("bignum", optarg)) {
_fetchOverflow = EvalPolicy::Bignum;
+ } else {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * @brief Whether @a optarg is a non-empty string of decimal digits (a valid
unsigned integer option).
+ */
+static bool
+isUnsignedInt(const char *optarg)
+{
+ if (nullptr == optarg || '\0' == *optarg) {
+ return false;
+ }
+ for (const char *p = optarg; '\0' != *p; ++p) {
Review Comment:
Good catch.
Switched both `--fetch-count` and `--fetch-max` to `std::from_chars()`
parsing directly into the destination `unsigned`, which reports out-of-range
and trailing junk in the same call. Added `prefetch_bad_count_refused` to cover
it; it fails against the previous code.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]