diff mbox

Btrfs: clean up an error code in btrfs_init_space_info()

Message ID 20160113122117.GB19993@mwanda (mailing list archive)
State Superseded
Headers show

Commit Message

Dan Carpenter Jan. 13, 2016, 12:21 p.m. UTC
If we return 1 here, then the caller treats it as an error and returns
-EINVAL.  It causes a static checker warning to treat positive returns
as an error.

Fixes: 1aba86d67f34 ('Btrfs: fix easily get into ENOSPC in mixed case')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I would appreciate a little review here.  This patch doesn't change
behavior, but it's possible that we had intended to do something else.

--
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

Comments

David Sterba Jan. 13, 2016, 1:31 p.m. UTC | #1
On Wed, Jan 13, 2016 at 03:21:17PM +0300, Dan Carpenter wrote:
> If we return 1 here, then the caller treats it as an error and returns
> -EINVAL.  It causes a static checker warning to treat positive returns
> as an error.
> 
> Fixes: 1aba86d67f34 ('Btrfs: fix easily get into ENOSPC in mixed case')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I would appreciate a little review here.  This patch doesn't change
> behavior, but it's possible that we had intended to do something else.

No, it makes sense to switch it to -EINVAL. Thanks.

Reviewed-by: David Sterba <dsterba@suse.com>
--
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
Liu Bo Jan. 13, 2016, 6:16 p.m. UTC | #2
On Wed, Jan 13, 2016 at 03:21:17PM +0300, Dan Carpenter wrote:
> If we return 1 here, then the caller treats it as an error and returns
> -EINVAL.  It causes a static checker warning to treat positive returns
> as an error.
> 
> Fixes: 1aba86d67f34 ('Btrfs: fix easily get into ENOSPC in mixed case')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I would appreciate a little review here.  This patch doesn't change
> behavior, but it's possible that we had intended to do something else.
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 60cc139..64649f8e 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -10586,7 +10586,7 @@ int btrfs_init_space_info(struct btrfs_fs_info *fs_info)
>  
>  	disk_super = fs_info->super_copy;
>  	if (!btrfs_super_root(disk_super))
> -		return 1;
> +		return -EINVAL;

Thank you for this, Dan.

While we're here, I'd suggest to remove this check as tree_root->node has already been readed from btrfs_super_root().

Thanks,

-liubo

>  
>  	features = btrfs_super_incompat_flags(disk_super);
>  	if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)
--
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/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 60cc139..64649f8e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10586,7 +10586,7 @@  int btrfs_init_space_info(struct btrfs_fs_info *fs_info)
 
 	disk_super = fs_info->super_copy;
 	if (!btrfs_super_root(disk_super))
-		return 1;
+		return -EINVAL;
 
 	features = btrfs_super_incompat_flags(disk_super);
 	if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)