From e5805287d01edd8f81641b126defc5b3ad366d2c Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 19 Dec 2016 11:22:30 -0800 Subject: [PATCH] usb_updater: initialize corrupt_inactive_rw before using it The earlier change introduced the uninitialized variable bug, which was not caught by the compiler. Let's make sure the variable is always initialized, and also let's add a message informing the user that the binary image is ignored when -f or -c command line options are given. BRANCH=none BUG=chrome-os-partner:55667 TEST=there is no accidental attempts to erase the inactive firmware any more. The message is printed when the binary image is ignored. Change-Id: If67841fa3933e7c2df772348ed5308ff722a6e3a Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/421498 Reviewed-by: Bill Richardson --- extra/usb_updater/usb_updater.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c index 04e5b615f0..e41c3027b1 100644 --- a/extra/usb_updater/usb_updater.c +++ b/extra/usb_updater/usb_updater.c @@ -1198,7 +1198,7 @@ int main(int argc, char *argv[]) int transferred_sections = 0; int binary_vers = 0; int show_fw_ver = 0; - int corrupt_inactive_rw; + int corrupt_inactive_rw = 0; progname = strrchr(argv[0], '/'); if (progname) @@ -1281,6 +1281,9 @@ int main(int argc, char *argv[]) if (binary_vers) exit(show_headers_versions(data)); + } else { + if (optind < argc) + printf("Ignoring binary image %s\n", argv[optind]); } if (td.ep_type == usb_xfer) {