From ab20706a842d14ed1b2fbe0c52fa6851a41eeb94 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 21 May 2018 14:48:49 -0700 Subject: updater: Clean up the header lines computation. It no longer needs to be conditional, as we've removed the support for BBOTA v1/v2. Test: mmma bootable/recovery Change-Id: I881de8afa38cc5b41b48e6d48d85170699ea5eb4 --- updater/blockimg.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index 236644e7f..48d1f4e10 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1666,7 +1666,6 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, return StringValue("t"); } - size_t start = 2; if (lines.size() < 4) { ErrorAbort(state, kArgsParsingFailure, "too few lines in the transfer list [%zu]", lines.size()); @@ -1708,8 +1707,6 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, saved_last_command_index = -1; } - start += 2; - // Build a map of the available commands std::unordered_map cmd_map; for (size_t i = 0; i < cmdcount; ++i) { @@ -1722,17 +1719,18 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int rc = -1; + static constexpr size_t kTransferListHeaderLines = 4; // Subsequent lines are all individual transfer commands - for (size_t i = start; i < lines.size(); i++) { + for (size_t i = kTransferListHeaderLines; i < lines.size(); i++) { const std::string& line = lines[i]; if (line.empty()) continue; params.tokens = android::base::Split(line, " "); params.cpos = 0; - if (i - start > std::numeric_limits::max()) { + if (i - kTransferListHeaderLines > std::numeric_limits::max()) { params.cmdindex = -1; } else { - params.cmdindex = i - start; + params.cmdindex = i - kTransferListHeaderLines; } params.cmdname = params.tokens[params.cpos++].c_str(); params.cmdline = line.c_str(); -- cgit v1.2.3