diff mbox

[09/16] btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error

Message ID 1383779755-18228-10-git-send-email-sandeen@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Eric Sandeen Nov. 6, 2013, 11:15 p.m. UTC
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>
---
 cmds-filesystem.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Anand Jain Nov. 7, 2013, 4:29 a.m. UTC | #1
Reviewed-by: Anand Jain <anand.jain@oracle.com>


On 11/07/2013 07:15 AM, Eric Sandeen wrote:
> 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>
> ---
>   cmds-filesystem.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cmds-filesystem.c b/cmds-filesystem.c
> index e6642ef..df9d1ff 100644
> --- a/cmds-filesystem.c
> +++ b/cmds-filesystem.c
> @@ -362,13 +362,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);
>   	}
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index e6642ef..df9d1ff 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -362,13 +362,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);
 	}