btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error

The error return from open is -1, so test that, not 0,
for success/failure.

Resolves-Coverity-CID: 1125931
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
master
Eric Sandeen 2013-11-06 17:15:48 -06:00 committed by Chris Mason
parent 249b93b5ef
commit 09aa5d3601
1 changed files with 2 additions and 2 deletions

View File

@ -371,13 +371,13 @@ static int btrfs_scan_kernel(void *search)
}
fd = open(mnt->mnt_dir, O_RDONLY);
if (fd > 0 && !get_df(fd, &space_info_arg)) {
if ((fd != -1) && !get_df(fd, &space_info_arg)) {
get_label_mounted(mnt->mnt_dir, label);
print_one_fs(&fs_info_arg, dev_info_arg,
space_info_arg, label, mnt->mnt_dir);
free(space_info_arg);
}
if (fd > 0)
if (fd != -1)
close(fd);
free(dev_info_arg);
}