Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e942fea authored by Elliott Hughes's avatar Elliott Hughes Committed by Rom Lemarchand
Browse files

Cope with angler's whitespace-padded partition size reporting.

Before:

  $ fastboot -w
  wiping userdata...
  Couldn't parse partition size '0x        0x66257ee00'.
  wiping cache...
  Couldn't parse partition size '0x        0x6400000'.
  erasing 'userdata'...

Bug: http://b/25653580

(cherry picked from commit a2db2618)

Change-Id: I15e6bee4d88695d4482013c4f86586276acdea84
parent 2812011c
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -1027,6 +1027,11 @@ static void fb_perform_format(usb_handle* usb,
        }
        }
        partition_size = size_override;
        partition_size = size_override;
    }
    }
    // Some bootloaders (angler, for example), send spurious leading whitespace.
    partition_size = android::base::Trim(partition_size);
    // 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;


    gen = fs_get_generator(partition_type);
    gen = fs_get_generator(partition_type);
    if (!gen) {
    if (!gen) {
@@ -1040,10 +1045,6 @@ static void fb_perform_format(usb_handle* usb,
        return;
        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;
    int64_t size;
    if (!android::base::ParseInt(partition_size.c_str(), &size)) {
    if (!android::base::ParseInt(partition_size.c_str(), &size)) {
        fprintf(stderr, "Couldn't parse partition size '%s'.\n", partition_size.c_str());
        fprintf(stderr, "Couldn't parse partition size '%s'.\n", partition_size.c_str());