Use only signed/unsigned numbers with ParseInt/ParseUint respectively
Test: build
Change-Id: Id6f4ca226cef76adef5dba4e3094bbd02a0badf0
diff --git a/Android.bp b/Android.bp
index b0f9456..96b2e8c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -16,6 +16,7 @@
name: "libgtest_isolated",
host_supported: true,
cflags: ["-Wall", "-Werror"],
+ cpp_std: "c++17",
export_include_dirs: ["include"],
srcs: [
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 {