tests/bios-tables-test: check the value returned by fopen()

The function fopen() may fail, so check its return value.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Li Liu <john.liuli@huawei.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
zhanghailiang 2014-08-18 15:54:33 +08:00 committed by Michael Tokarev
parent d70724cec8
commit c39a28a43d

View File

@ -790,6 +790,11 @@ int main(int argc, char *argv[])
const char *arch = qtest_get_arch();
FILE *f = fopen(disk, "w");
int ret;
if (!f) {
fprintf(stderr, "Couldn't open \"%s\": %s", disk, strerror(errno));
return 1;
}
fwrite(boot_sector, 1, sizeof boot_sector, f);
fclose(f);