Skip to contentSkip to conversation

btrfs: remove open-coded swap() in backref.c:__merge_refs

PATCH Dave Jones 1 participant 2 messages Jan 28, 2016 Btrfs file system

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

The kernel provides a swap() that does the same thing as this code.

fs/btrfs/backref.c +3 -6
index b90cd3776f8e..626bf6c12992 100644
@@ -566,17 +566,14 @@ static void __merge_refs(struct list_head *head, int mode)
 		struct __prelim_ref *pos2 = pos1, *tmp;
 
 		list_for_each_entry_safe_continue(pos2, tmp, head, list) {
-			struct __prelim_ref *xchg, *ref1 = pos1, *ref2 = pos2;
+			struct __prelim_ref *ref1 = pos1, *ref2 = pos2;
 			struct extent_inode_elem *eie;
 
 			if (!ref_for_same_block(ref1, ref2))
 				continue;
 			if (mode == 1) {
-				if (!ref1->parent && ref2->parent) {
-					xchg = ref1;
-					ref1 = ref2;
-					ref2 = xchg;
-				}
+				if (!ref1->parent && ref2->parent)
+					swap(ref1, ref1);
 			} else {
 				if (ref1->parent != ref2->parent)
 					continue;
author
#1 lore raw

The kernel provides a swap() that does the same thing as this code.

Signature · 1 line
v2: Was swapping the same var. duh.
fs/btrfs/backref.c +3 -6
index b90cd3776f8e..626bf6c12992 100644
@@ -566,17 +566,14 @@ static void __merge_refs(struct list_head *head, int mode)
 		struct __prelim_ref *pos2 = pos1, *tmp;
 
 		list_for_each_entry_safe_continue(pos2, tmp, head, list) {
-			struct __prelim_ref *xchg, *ref1 = pos1, *ref2 = pos2;
+			struct __prelim_ref *ref1 = pos1, *ref2 = pos2;
 			struct extent_inode_elem *eie;
 
 			if (!ref_for_same_block(ref1, ref2))
 				continue;
 			if (mode == 1) {
-				if (!ref1->parent && ref2->parent) {
-					xchg = ref1;
-					ref1 = ref2;
-					ref2 = xchg;
-				}
+				if (!ref1->parent && ref2->parent)
+					swap(ref1, ref2);
 			} else {
 				if (ref1->parent != ref2->parent)
 					continue;