summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2016-07-28 17:29:49 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-28 17:29:49 +0000
commitc116d4c203892c5bcef57bd01b93bf15e5b9d722 (patch)
tree2f8084d7b2ccc65b879e04bceabf63458a2d181a
parent4198f881670907ee592f3b23f7c0655c529f6f1d (diff)
parent52d6ebfffb908111cd129134503cf60124e79e47 (diff)
downloadandroid_system_tools_aidl-c116d4c203892c5bcef57bd01b93bf15e5b9d722.tar.gz
android_system_tools_aidl-c116d4c203892c5bcef57bd01b93bf15e5b9d722.tar.bz2
android_system_tools_aidl-c116d4c203892c5bcef57bd01b93bf15e5b9d722.zip
aidl-cpp: Use |ParseInt| util for hex conversion am: 9d7810ac16 am: 14e533e2cf am: 59f193df6a
am: 52d6ebfffb Change-Id: I51f36a5393586c5748081fc7da84e2c7ea3b6743
-rw-r--r--aidl_language.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 6af55f8..bbe305b 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -6,6 +6,7 @@
#include <string.h>
#include <string>
+#include <android-base/parseint.h>
#include <android-base/strings.h>
#include "aidl_language_y.h"
@@ -96,19 +97,14 @@ AidlIntConstant::AidlIntConstant(std::string name,
std::string value,
unsigned line_number)
: name_(name) {
- char *end;
- // Use long long to ensure 0xFFFFFFFF -> -1 works on 32 bit devices.
- unsigned long long int long_value = std::strtoull(value.c_str(), &end, 16);
- // Ensure that we parsed the string fully and the value fits in int32.
- if ((*end != '\0') ||
- ((long_value == ULLONG_MAX) && (errno == ERANGE)) ||
- (long_value > std::numeric_limits<uint32_t>::max())) {
+ uint32_t unsigned_val;
+ if (!android::base::ParseUint(value.c_str(), &unsigned_val)) {
is_valid_ = false;
LOG(ERROR) << "Found invalid int value '" << value
<< "' on line " << line_number;
} else {
- // Converting from unsigned long to signed integer.
- value_ = long_value;
+ // Converting from unsigned to signed integer.
+ value_ = unsigned_val;
is_valid_ = true;
}
}