From 9a8dfd00ecf042b7619f0fbbcb8308fce5cfd5c8 Mon Sep 17 00:00:00 2001 From: "Nam T. Nguyen" Date: Mon, 26 Jan 2015 12:55:05 -0800 Subject: 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 Commit-Queue: Nam Nguyen Trybot-Ready: Nam Nguyen Tested-by: Nam Nguyen --- cgpt/cgpt_wrapper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cgpt') diff --git a/cgpt/cgpt_wrapper.c b/cgpt/cgpt_wrapper.c index 50957ccb..f9288c15 100644 --- a/cgpt/cgpt_wrapper.c +++ b/cgpt/cgpt_wrapper.c @@ -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; } } -- cgit v1.2.1