2016-12-03 10:55:57

by Pan Bian

[permalink] [raw]
Subject: [PATCH 1/1] btrfs: fix improper return value

In function btrfs_uuid_tree_iterate(), errno is assigned to variable
ret on errors. However, it directly returns 0. It may be better to
return ret.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188731

Signed-off-by: Pan Bian <[email protected]>
---
fs/btrfs/uuid-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 7fc89e4..44bcc1f 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -353,5 +353,5 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
btrfs_free_path(path);
if (ret)
btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
- return 0;
+ return ret;
}
--
1.9.1



2016-12-03 18:53:40

by Omar Sandoval

[permalink] [raw]
Subject: Re: [PATCH 1/1] btrfs: fix improper return value

On Sat, Dec 03, 2016 at 06:55:16PM +0800, Pan Bian wrote:
> In function btrfs_uuid_tree_iterate(), errno is assigned to variable
> ret on errors. However, it directly returns 0. It may be better to
> return ret.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188731
>
> Signed-off-by: Pan Bian <[email protected]>
> ---
> fs/btrfs/uuid-tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
> index 7fc89e4..44bcc1f 100644
> --- a/fs/btrfs/uuid-tree.c
> +++ b/fs/btrfs/uuid-tree.c
> @@ -353,5 +353,5 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
> btrfs_free_path(path);
> if (ret)
> btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
> - return 0;
> + return ret;

This one makes sense, since the caller is checking the return value. The
caller is already printing a warning, can you also get rid of the
btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret)?