btrfs-progs: check for open failure, don't close

Check for failure by testing for a negative file descriptor, not a
descriptor of 0.  And if it failed we have nothing to close().

Signed-off-by: Zach Brown <zab@redhat.com>
master
Zach Brown 2013-01-22 13:48:04 -08:00
parent 201238df26
commit 7c9f323a7c
1 changed files with 1 additions and 2 deletions

View File

@ -87,9 +87,8 @@ static int cmd_add_dev(int argc, char **argv)
}
devfd = open(argv[i], O_RDWR);
if (!devfd) {
if (devfd < 0) {
fprintf(stderr, "ERROR: Unable to open device '%s'\n", argv[i]);
close(devfd);
ret++;
continue;
}