update_engine: Silence errors from CanResumeUpdate()
TEST_AND_RETURN_FALSE macro will log an ERROR when the value is false.
This macro is often used to bubble up errors. In the case of
CanResumeUpdate(), if the update can't be resumed (as happens with every
new update) it still logs a not so descriptive ERROR message.
This patch silence the LOG messages from CanResumeUpdate() calls.
There's already a log message for "Restarting" or "Starting" a new
update.
BUG=None
TEST=unittest still pass.
Change-Id: Iaf51c0a00f40ed9dd9cc96dcd5fcaabcb78049f4
Reviewed-on: https://chromium-review.googlesource.com/263133
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/delta_performer.cc b/delta_performer.cc
index 825084d..e6441fe 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -1309,37 +1309,37 @@
bool DeltaPerformer::CanResumeUpdate(PrefsInterface* prefs,
string update_check_response_hash) {
int64_t next_operation = kUpdateStateOperationInvalid;
- TEST_AND_RETURN_FALSE(prefs->GetInt64(kPrefsUpdateStateNextOperation,
- &next_operation) &&
- next_operation != kUpdateStateOperationInvalid &&
- next_operation > 0);
+ if (!(prefs->GetInt64(kPrefsUpdateStateNextOperation, &next_operation) &&
+ next_operation != kUpdateStateOperationInvalid &&
+ next_operation > 0))
+ return false;
string interrupted_hash;
- TEST_AND_RETURN_FALSE(prefs->GetString(kPrefsUpdateCheckResponseHash,
- &interrupted_hash) &&
- !interrupted_hash.empty() &&
- interrupted_hash == update_check_response_hash);
+ if (!(prefs->GetString(kPrefsUpdateCheckResponseHash, &interrupted_hash) &&
+ !interrupted_hash.empty() &&
+ interrupted_hash == update_check_response_hash))
+ return false;
int64_t resumed_update_failures;
- TEST_AND_RETURN_FALSE(!prefs->GetInt64(kPrefsResumedUpdateFailures,
- &resumed_update_failures) ||
- resumed_update_failures <= kMaxResumedUpdateFailures);
+ if (!(prefs->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)
+ && resumed_update_failures > kMaxResumedUpdateFailures))
+ return false;
// Sanity check the rest.
int64_t next_data_offset = -1;
- TEST_AND_RETURN_FALSE(prefs->GetInt64(kPrefsUpdateStateNextDataOffset,
- &next_data_offset) &&
- next_data_offset >= 0);
+ if (!(prefs->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset) &&
+ next_data_offset >= 0))
+ return false;
string sha256_context;
- TEST_AND_RETURN_FALSE(
- prefs->GetString(kPrefsUpdateStateSHA256Context, &sha256_context) &&
- !sha256_context.empty());
+ if (!(prefs->GetString(kPrefsUpdateStateSHA256Context, &sha256_context) &&
+ !sha256_context.empty()))
+ return false;
int64_t manifest_metadata_size = 0;
- TEST_AND_RETURN_FALSE(prefs->GetInt64(kPrefsManifestMetadataSize,
- &manifest_metadata_size) &&
- manifest_metadata_size > 0);
+ if (!(prefs->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size) &&
+ manifest_metadata_size > 0))
+ return false;
return true;
}