[vdisk/qcow2] Handle the return value of open(2) properly

This commit is contained in:
Ivan Baravy 2023-02-16 19:26:31 +00:00
parent 99515bca17
commit e027ef8ea9

View File

@ -213,7 +213,7 @@ vdisk_init_qcow2(const char *fname, const struct umka_io *io) {
};
d->vdisk.io = io;
d->prev_cluster_index = ~(uint64_t)0;
if (!(d->fd = open(fname, O_RDONLY | O_BINARY))) {
if ((d->fd = open(fname, O_RDONLY | O_BINARY)) == -1) {
fprintf(stderr, "[vdisk.qcow2] can't open file '%s': %s\n", fname,
strerror(errno));
vdisk_qcow2_close(d);