summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-11-03 16:55:42 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-11-03 16:55:42 +0000
commit4ca547be67ed1b65c5ced5eeafdb6fe8fe3c3011 (patch)
tree6d7a0e026bb25e04e97309691ceacf691880cd47 /fastboot/fastboot.cpp
parentaff48cbb3fce8c1529181166f21e8b9952b47f2d (diff)
parent2b7b3bd100747fb7a02f1d8c7c2e8a5ee6cdc82f (diff)
Merge "Fix fastboot to cope with hammerhead\'s implicit hex."
am: 2b7b3bd100 * commit '2b7b3bd100747fb7a02f1d8c7c2e8a5ee6cdc82f': Fix fastboot to cope with hammerhead's implicit hex.
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 3b25a8296..15dd67d46 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -576,7 +576,7 @@ static struct sparse_file **load_sparse_files(int fd, int max_size)
static int64_t get_target_sparse_limit(usb_handle* usb) {
std::string max_download_size;
- if (!fb_getvar(usb, "max-download-size", &max_download_size)) {
+ if (!fb_getvar(usb, "max-download-size", &max_download_size) || max_download_size.empty()) {
fprintf(stderr, "target didn't report max-download-size\n");
return 0;
}
@@ -935,6 +935,10 @@ static void fb_perform_format(usb_handle* usb,
return;
}
+ // Some bootloaders (hammerhead, for example) use implicit hex.
+ // This code used to use strtol with base 16.
+ if (!android::base::StartsWith(partition_size, "0x")) partition_size = "0x" + partition_size;
+
int64_t size;
if (!android::base::ParseInt(partition_size.c_str(), &size)) {
fprintf(stderr, "Couldn't parse partition size '%s'.\n", partition_size.c_str());