summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-09-04 15:52:10 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-07 14:29:04 -0700
commite5cd1b321916df9c36770f06d28ec86bca98d116 (patch)
treef2894fc679b3827ce1e0586e2ba4109021f0e32d
parent5ed334d26cba9be660ad46c186e46e830993aa98 (diff)
downloadvboot-e5cd1b321916df9c36770f06d28ec86bca98d116.tar.gz
futility: cmd_update: Correctly handle error counter
The errorcnt in do_update should not add function return values directly because the function may return negative values, which would lead to wrong results. Instead we can process using '!!' so the returned value will always be zero or positive integers. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I9f450b2ee8d86035288f06bdb314dfb1dce3ca64 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1209023 Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r--futility/cmd_update.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c
index a62e86e2..3c12d565 100644
--- a/futility/cmd_update.c
+++ b/futility/cmd_update.c
@@ -1529,13 +1529,13 @@ static int do_update(int argc, char *argv[])
while ((i = getopt_long(argc, argv, short_opts, long_opts, 0)) != -1) {
switch (i) {
case 'i':
- errorcnt += load_image(optarg, &cfg.image);
+ errorcnt += !!load_image(optarg, &cfg.image);
break;
case 'e':
- errorcnt += load_image(optarg, &cfg.ec_image);
+ errorcnt += !!load_image(optarg, &cfg.ec_image);
break;
case 'P':
- errorcnt += load_image(optarg, &cfg.pd_image);
+ errorcnt += !!load_image(optarg, &cfg.pd_image);
break;
case 't':
cfg.try_update = 1;
@@ -1564,7 +1564,7 @@ static int do_update(int argc, char *argv[])
break;
case 'E':
cfg.emulate = 1;
- errorcnt += emulate_system_image(
+ errorcnt += !!emulate_system_image(
optarg, &cfg.image_current);
/* Both image and image_current need emulation. */
if (!errorcnt) {