summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-09-24 20:10:51 +0200
committerTao Bao <tbao@google.com>2015-09-24 21:14:37 +0200
commitb15fd224edcab95732fbfaa237c7b9cde9c23812 (patch)
tree4758701194d4aae6f8bc8b782e583b7fe83e98d1 /updater/install.cpp
parentSuppress some compiler warnings due to signedness. (diff)
downloadandroid_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar.gz
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar.bz2
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar.lz
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar.xz
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.tar.zst
android_bootable_recovery-b15fd224edcab95732fbfaa237c7b9cde9c23812.zip
Diffstat (limited to 'updater/install.cpp')
-rw-r--r--updater/install.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index 68c990241..97e390560 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -34,6 +34,7 @@
#include <linux/xattr.h>
#include <inttypes.h>
+#include <base/parseint.h>
#include <base/strings.h>
#include <base/stringprintf.h>
@@ -474,7 +475,8 @@ Value* ShowProgressFn(const char* name, State* state, int argc, Expr* argv[]) {
}
double frac = strtod(frac_str, NULL);
- int sec = strtol(sec_str, NULL, 10);
+ int sec;
+ android::base::ParseInt(sec_str, &sec);
UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
fprintf(ui->cmd_pipe, "progress %f %d\n", frac, sec);
@@ -1145,12 +1147,11 @@ Value* ApplyPatchSpaceFn(const char* name, State* state,
return NULL;
}
- char* endptr;
- size_t bytes = strtol(bytes_str, &endptr, 10);
- if (bytes == 0 && endptr == bytes_str) {
+ size_t bytes;
+ if (!android::base::ParseUint(bytes_str, &bytes)) {
ErrorAbort(state, "%s(): can't parse \"%s\" as byte count\n\n", name, bytes_str);
free(bytes_str);
- return NULL;
+ return nullptr;
}
return StringValue(strdup(CacheSizeCheck(bytes) ? "" : "t"));
@@ -1174,16 +1175,14 @@ Value* ApplyPatchFn(const char* name, State* state, int argc, Expr* argv[]) {
return NULL;
}
- char* endptr;
- size_t target_size = strtol(target_size_str, &endptr, 10);
- if (target_size == 0 && endptr == target_size_str) {
- ErrorAbort(state, "%s(): can't parse \"%s\" as byte count",
- name, target_size_str);
+ size_t target_size;
+ if (!android::base::ParseUint(target_size_str, &target_size)) {
+ ErrorAbort(state, "%s(): can't parse \"%s\" as byte count", name, target_size_str);
free(source_filename);
free(target_filename);
free(target_sha1);
free(target_size_str);
- return NULL;
+ return nullptr;
}
int patchcount = (argc-4) / 2;
@@ -1523,7 +1522,8 @@ Value* WipeBlockDeviceFn(const char* name, State* state, int argc, Expr* argv[])
char* len_str;
if (ReadArgs(state, argv, 2, &filename, &len_str) < 0) return NULL;
- size_t len = strtoull(len_str, NULL, 0);
+ size_t len;
+ android::base::ParseUint(len_str, &len);
int fd = open(filename, O_WRONLY, 0644);
int success = wipe_block_device(fd, len);