From ffede3e8d9b2a6cb6c431ccad69cb341c22f7e45 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 7 Jun 2018 09:56:19 -0700 Subject: updater: Remove the redundant check on line count. Test: recovery_component_test on marlin. Change-Id: I2ac2bd47469d1aec8a97a8c4ed0fe80ffd65c95b --- updater/blockimg.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'updater') diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index f2811bccf..1646b7c17 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1628,9 +1628,10 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, } } + static constexpr size_t kTransferListHeaderLines = 4; std::vector lines = android::base::Split(transfer_list_value->data, "\n"); - if (lines.size() < 2) { - ErrorAbort(state, kArgsParsingFailure, "too few lines in the transfer list [%zd]", + if (lines.size() < kTransferListHeaderLines) { + ErrorAbort(state, kArgsParsingFailure, "too few lines in the transfer list [%zu]", lines.size()); return StringValue(""); } @@ -1654,12 +1655,6 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, return StringValue("t"); } - if (lines.size() < 4) { - ErrorAbort(state, kArgsParsingFailure, "too few lines in the transfer list [%zu]", - lines.size()); - return StringValue(""); - } - // Third line is how many stash entries are needed simultaneously. LOG(INFO) << "maximum stash entries " << lines[2]; @@ -1698,7 +1693,6 @@ 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 = kTransferListHeaderLines; i < lines.size(); i++) { const std::string& line = lines[i]; -- cgit v1.2.3