Skip to contentSkip to conversation

btrfs: Remove never-reached WARN_ON

PATCH Superseded Nikolay Borisov 2 participants 3 messages Aug 17, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Remove never-reached WARN_ON

We have a WARN_ON(!var) inside an if branch which is executed (among others) only when var is true.

---
 fs/btrfs/extent-tree.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/extent-tree.c +0 -1
index 21c78c48e15b..8552d550a048 100644
@@ -6755,7 +6755,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
 			u64 to_add = len;
-			WARN_ON(!return_free_space);
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
 				to_add = min(len, global_rsv->size -
Signature · 1 line
2.7.4
#1 lore raw
Quoted 13 lines · Nikolay Borisov

We have a WARN_ON(!var) inside an if branch which is executed (among others) only when var is true.

---
 fs/btrfs/extent-tree.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/extent-tree.c +0 -0
index 21c78c48e15b..8552d550a048 100644

fs/btrfs/extent-tree.c static int unpin_extent_range(struct btrfs_fs_info *fs_info, · line 6758

Quoted 4 lines
fs/btrfs/extent-tree.c +0 -1
@@ -6755,7 +6755,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
 			u64 to_add = len;
-			WARN_ON(!return_free_space);

Right. And also an example where the coding style can be improved as a sideefect, ie. the missing line between declarations and statements.

Quoted 10 lines
fs/btrfs/extent-tree.c +0 -0
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
 				to_add = min(len, global_rsv->size -
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH v2 1/1 btrfs: Remove never-reached WARN_ON

We have a WARN_ON(!var) inside an if branch which is executed (among others) only when var is true.

---
 fs/btrfs/extent-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +2 -1
index 21c78c48e15b..8b32e53236ea 100644
@@ -6755,7 +6755,7 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
 			u64 to_add = len;
-			WARN_ON(!return_free_space);
+
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
 				to_add = min(len, global_rsv->size -
@@ -6771,6 +6771,7 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 				len -= to_add;
 			}
 			spin_unlock(&global_rsv->lock);
+
 			/* Add to any tickets we may have */
 			if (len)
 				space_info_add_new_bytes(fs_info, space_info,
Signature · 1 line
2.7.4