summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2018-10-08 12:41:50 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-10-08 12:41:50 -0700
commitcae2666818db99c55df09b45bf8347f4d5b958d6 (patch)
tree69a0f23852e7a13cbff81d9310b0f455d579b76b
parentf83622fa1454eed1e4d965066c65aeb257c2b155 (diff)
parent0097dd2cf28954c6ac059dd01c85a3f6ef2fb8fe (diff)
downloadgtest_extras-cae2666818db99c55df09b45bf8347f4d5b958d6.tar.gz
Use only signed/unsigned numbers with ParseInt/ParseUint respectively am: 66062ee874
am: 0097dd2cf2 Change-Id: Id7e42fb628a42fb9bac66ad8dca49b31f64f264b
-rw-r--r--Android.bp1
-rw-r--r--Options.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/Android.bp b/Android.bp
index b0f9456..96b2e8c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -16,6 +16,7 @@ cc_library {
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 @@ static void PrintError(const std::string& arg, std::string msg, bool from_env) {
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 {