util/iteflash.c: make sure that the file is closed

An insignificant bug, but Coverity complains about it. Reduce the
cognitive load by making sure that file is closed in time.

BUG=none
BRANCH=none
TEST=none

Change-Id: I2efbe136f4991cf829b95568eef22eb7b2d1a8c6
Found-by: Coverity Scan #141758
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/702304
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Chris Ching <chingcodes@chromium.org>
This commit is contained in:
Patrick Georgi
2017-10-05 15:44:24 +02:00
committed by chrome-bot
parent 57ae0b0f18
commit 828da3d556

View File

@@ -916,12 +916,12 @@ int verify_flash(struct ftdi_context *ftdi, const char *filename,
}
file_size = fread(buffer, 1, flash_size, hnd);
fclose(hnd);
if (file_size <= 0) {
fprintf(stderr, "Cannot read %s\n", filename);
res = -EIO;
goto exit;
}
fclose(hnd);
printf("Verify %d bytes at 0x%08x\n", file_size, offset);
res = command_read_pages(ftdi, offset, flash_size, buffer2);