Skip to contentSkip to conversation

btrfs: remove unneeded variable from unpin_extent_cache()

PATCH In review [email protected] 3 participants 3 messages Jun 14, 2023 1 message not in the archive Btrfs file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 btrfs: remove unneeded variable from unpin_extent_cache()

fix the following coccicheck warning:

fs/btrfs/extent_map.c:298:5-8: Unneeded variable: "ret". Return "0".

---
 fs/btrfs/extent_map.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/extent_map.c +0 -0
index 0cdb3e86f29b..f3e9aaeb9956 100644
@@ -295,7 +295,6 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
 int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 

len,

                u64 gen)
 {
-    int ret = 0;
     struct extent_map *em;
     bool prealloc = false;

@@ -327,7 +326,7 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,

     free_extent_map(em);
 out:
     write_unlock(&tree->lock);

- return ret;
+ return 0;

}

#3 lore raw
In reply to [email protected]
Quoted 5 lines · On 2023/6/14 14:59, [email protected] wrote:

fix the following coccicheck warning:

fs/btrfs/extent_map.c:298:5-8: Unneeded variable: "ret". Return "0".

You can take it one step further by making the function return void.

Thanks,
Qu

Quoted 26 lines
---
  fs/btrfs/extent_map.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/extent_map.c +1 -2
index 0cdb3e86f29b..f3e9aaeb9956 100644
@@ -295,7 +295,6 @@ static void try_merge_map(struct extent_map_tree
 *tree, struct extent_map *em)
  int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
                 u64 gen)
  {
-    int ret = 0;
      struct extent_map *em;
      bool prealloc = false;
@@ -327,7 +326,7 @@ int unpin_extent_cache(struct extent_map_tree *tree,
 u64 start, u64 len,
      free_extent_map(em);
  out:
      write_unlock(&tree->lock);
-    return ret;
+    return 0;
 
  }