Skip to contentSkip to conversation

ocfs2: Remove some redundant casting

PATCH New George Spelvin 2 participants 2 messages May 9, 2014 – May 14, 2014 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: Remove some redundant casting

There are two standard techniques for dereferencing structures pointed to by void *: cast to the right type each time they're used, or assign to local variables of the right type.

But there's no need to do *both*.

---
Obviously, this makes zero difference to the generated code, but it's prettier.

fs/ocfs2/refcounttree.c +3 -4
index 6ba4bcbc47..714e53b9cc 100644
@@ -1408,10 +1408,9 @@ static void swap_refcount_rec(void *a, void *b, int size)
 {
 	struct ocfs2_refcount_rec *l = a, *r = b, tmp;
 
-	tmp = *(struct ocfs2_refcount_rec *)l;
-	*(struct ocfs2_refcount_rec *)l =
-			*(struct ocfs2_refcount_rec *)r;
-	*(struct ocfs2_refcount_rec *)r = tmp;
+	tmp = *l;
+	*l = *r;
+	*r = tmp;
 }
 
 /*
#1 lore raw

PATCH 1/1 ocfs2: Remove some redundant casting

Tao's Oracle email address was obsolete.

Quoted 10 lines · George Spelvin

There are two standard techniques for dereferencing structures pointed to by void *: cast to the right type each time they're used, or assign to local variables of the right type.

But there's no need to do *both*.

---
Obviously, this makes zero difference to the generated code, but it's prettier.

Indeed :), the patch looks good to me.

Thanks,
-Jeff