In some cases file descriptors equal to 0 are treated as invalid.
Fix it.
Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
if (dfd < 0 ||
st->ss->load_super(st, dfd, NULL))
tmpdev->used = 2;
- if (dfd > 0)
- close(dfd);
+ close_fd(&dfd);
}
}
* number of devices (On-Line Capacity Expansion) must be
* performed at the level of the container
*/
- if (fd > 0) {
- close(fd);
- fd = -1;
- }
+ close_fd(&fd);
rv = reshape_container(container, devname, -1, st, &info,
c->force, c->backup_file, c->verbose,
0, 0, 0);
return 1;
}
mdfd = open_dev_excl(ent->devnm);
- if (mdfd > 0) {
- close(mdfd);
+ if (is_fd_valid(mdfd)) {
+ close_fd(&mdfd);
if (sysfs_get_str(&mdi, NULL, "array_state",
buf, sizeof(buf)) > 0) {
if (strncmp(buf, "active", 6) == 0 ||
}
if (locked)
cluster_release_dlmlock();
- if (mdfd > 0)
- close(mdfd);
+ close_fd(&mdfd);
exit(rv);
}
pr_err("BUG: invalid raid disk\n");
goto out;
}
- if (d->state_fd > 0)
+ if (is_fd_valid(d->state_fd))
found[i]++;
}
ret = 2;