Use only signed/unsigned numbers with ParseInt/ParseUint respectively
Test: build
Change-Id: Id6f4ca226cef76adef5dba4e3094bbd02a0badf0
diff --git a/Options.cpp b/Options.cpp
index 59acb48..55f480c 100644
--- a/Options.cpp
+++ b/Options.cpp
@@ -83,7 +83,13 @@
template <typename IntType>
static bool GetNumeric(const char* arg, const char* value, IntType* numeric_value, bool from_env) {
- if (!android::base::ParseInt<IntType>(value, numeric_value)) {
+ bool result = false;
+ if constexpr (std::is_unsigned<IntType>::value) {
+ result = android::base::ParseUint<IntType>(value, numeric_value);
+ } else {
+ result = android::base::ParseInt<IntType>(value, numeric_value);
+ }
+ if (!result) {
if (errno == ERANGE) {
PrintError(arg, std::string("value overflows (") + value + ")", from_env);
} else {