Message ID | 3dacbcffa8d7c4e70e934b8b977676a1072878f4.1710857863.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | trivial adjustments for return variable coding style | expand |
On Tue, Mar 19, 2024 at 08:25:31PM +0530, Anand Jain wrote: > First, rename ret to ret2, compile, and then rename err to 'ret', > to ensure that no original ret remains as the new ret. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > fs/btrfs/extent-tree.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c > index 1a1191efe59e..4b0a55e66a55 100644 > --- a/fs/btrfs/extent-tree.c > +++ b/fs/btrfs/extent-tree.c > @@ -448,9 +448,9 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, > struct btrfs_extent_data_ref *ref; > struct extent_buffer *leaf; > u32 nritems; > - int ret; > + int ret2; > int recow; > - int err = -ENOENT; > + int ret = -ENOENT; > > key.objectid = bytenr; > if (parent) { > @@ -463,14 +463,14 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, > } > again: > recow = 0; > - ret = btrfs_search_slot(trans, root, &key, path, -1, 1); > - if (ret < 0) { > - err = ret; > + ret2 = btrfs_search_slot(trans, root, &key, path, -1, 1); > + if (ret2 < 0) { > + ret = ret2; > goto fail; > } > > if (parent) { > - if (!ret) > + if (!ret2) > return 0; You don't need ret2, you can just rework this to if (parent) { if (ret) return -ENOENT; return 0; } > goto fail; > } > @@ -479,10 +479,10 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, > nritems = btrfs_header_nritems(leaf); > while (1) { > if (path->slots[0] >= nritems) { > - ret = btrfs_next_leaf(root, path); > - if (ret < 0) > - err = ret; > - if (ret) > + ret2 = btrfs_next_leaf(root, path); > + if (ret2 < 0) > + ret = ret2; > + if (ret2) > goto fail; Just rework this to ret = btrfs_next_leaf(root, path); if (ret) { if (ret > 1) return -ENOENT; return ret; } Thanks, Josef
On 3/20/24 02:17, Josef Bacik wrote: > On Tue, Mar 19, 2024 at 08:25:31PM +0530, Anand Jain wrote: >> First, rename ret to ret2, compile, and then rename err to 'ret', >> to ensure that no original ret remains as the new ret. >> >> Signed-off-by: Anand Jain <anand.jain@oracle.com> >> --- >> fs/btrfs/extent-tree.c | 24 ++++++++++++------------ >> 1 file changed, 12 insertions(+), 12 deletions(-) >> >> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c >> index 1a1191efe59e..4b0a55e66a55 100644 >> --- a/fs/btrfs/extent-tree.c >> +++ b/fs/btrfs/extent-tree.c >> @@ -448,9 +448,9 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, >> struct btrfs_extent_data_ref *ref; >> struct extent_buffer *leaf; >> u32 nritems; >> - int ret; >> + int ret2; >> int recow; >> - int err = -ENOENT; >> + int ret = -ENOENT; >> >> key.objectid = bytenr; >> if (parent) { >> @@ -463,14 +463,14 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, >> } >> again: >> recow = 0; >> - ret = btrfs_search_slot(trans, root, &key, path, -1, 1); >> - if (ret < 0) { >> - err = ret; >> + ret2 = btrfs_search_slot(trans, root, &key, path, -1, 1); >> + if (ret2 < 0) { >> + ret = ret2; >> goto fail; >> } >> >> if (parent) { >> - if (!ret) >> + if (!ret2) >> return 0; > > You don't need ret2, you can just rework this to > > if (parent) { > if (ret) > return -ENOENT; > return 0; > } > >> goto fail; >> } >> @@ -479,10 +479,10 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, This changes applied with the reinitialize of ret. + ret = -ENOENT; Thanks, Anand >> nritems = btrfs_header_nritems(leaf); >> while (1) { >> if (path->slots[0] >= nritems) { >> - ret = btrfs_next_leaf(root, path); >> - if (ret < 0) >> - err = ret; >> - if (ret) >> + ret2 = btrfs_next_leaf(root, path); >> + if (ret2 < 0) >> + ret = ret2; >> + if (ret2) >> goto fail; > > Just rework this to > > ret = btrfs_next_leaf(root, path); > if (ret) { > if (ret > 1) > return -ENOENT; > return ret; > } > > Thanks, > > Josef
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1a1191efe59e..4b0a55e66a55 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -448,9 +448,9 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, struct btrfs_extent_data_ref *ref; struct extent_buffer *leaf; u32 nritems; - int ret; + int ret2; int recow; - int err = -ENOENT; + int ret = -ENOENT; key.objectid = bytenr; if (parent) { @@ -463,14 +463,14 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, } again: recow = 0; - ret = btrfs_search_slot(trans, root, &key, path, -1, 1); - if (ret < 0) { - err = ret; + ret2 = btrfs_search_slot(trans, root, &key, path, -1, 1); + if (ret2 < 0) { + ret = ret2; goto fail; } if (parent) { - if (!ret) + if (!ret2) return 0; goto fail; } @@ -479,10 +479,10 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, nritems = btrfs_header_nritems(leaf); while (1) { if (path->slots[0] >= nritems) { - ret = btrfs_next_leaf(root, path); - if (ret < 0) - err = ret; - if (ret) + ret2 = btrfs_next_leaf(root, path); + if (ret2 < 0) + ret = ret2; + if (ret2) goto fail; leaf = path->nodes[0]; @@ -504,13 +504,13 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, btrfs_release_path(path); goto again; } - err = 0; + ret = 0; break; } path->slots[0]++; } fail: - return err; + return ret; } static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans,
First, rename ret to ret2, compile, and then rename err to 'ret', to ensure that no original ret remains as the new ret. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- fs/btrfs/extent-tree.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)