btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error
authorEric Sandeen <sandeen@redhat.com>
Wed, 6 Nov 2013 23:15:48 +0000 (17:15 -0600)
committerChris Mason <chris.mason@fusionio.com>
Thu, 7 Nov 2013 21:10:41 +0000 (16:10 -0500)
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>
cmds-filesystem.c

index e920b8a..376037b 100644 (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);
        }