cgpt_wrapper: Fix non-zero return code when okay

I forgot to reset "ret" to zero in the case the two hashes come out the
same. This CL fixes that silly logic bug.

BUG=None
BRANCH=None
TEST=`cgpt show /dev/mtd0` should exit with status 0

Change-Id: I1c64ea215c861c8afb44e235d090c72a5d006d55
Reviewed-on: https://chromium-review.googlesource.com/243325
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Trybot-Ready: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
This commit is contained in:
Nam T. Nguyen
2015-01-26 12:55:05 -08:00
committed by ChromeOS Commit Bot
parent f620c0d656
commit 9a8dfd00ec

View File

@@ -125,9 +125,10 @@ static int wrap_cgpt(int argc,
// Write back "rw_gpt" to NOR flash in two chunks.
ret++;
modified_hash = DigestFile(rw_gpt_path, SHA1_DIGEST_ALGORITHM);
if (original_hash != NULL && modified_hash != NULL &&
memcmp(original_hash, modified_hash, SHA1_DIGEST_SIZE) != 0) {
if (WriteNorFlash(temp_dir) == 0) {
if (original_hash != NULL && modified_hash != NULL) {
if (memcmp(original_hash, modified_hash, SHA1_DIGEST_SIZE) != 0) {
ret = WriteNorFlash(temp_dir);
} else {
ret = 0;
}
}