* [Ocfs2-devel] [PATCH] ocfs2: Remove some redundant casting
@ 2014-05-09 22:45 George Spelvin
2014-05-14 2:51 ` Jeff Liu
0 siblings, 1 reply; 2+ messages in thread
From: George Spelvin @ 2014-05-09 22:45 UTC (permalink / raw)
To: ocfs2-devel
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*.
Signed-off-by: George Spelvin <linux@horizon.com>
---
Obviously, this makes zero difference to the generated code, but
it's prettier.
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 6ba4bcbc47..714e53b9cc 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -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;
}
/*
^ permalink raw reply related [flat|nested] 2+ messages in thread* [Ocfs2-devel] [PATCH] ocfs2: Remove some redundant casting
2014-05-09 22:45 [Ocfs2-devel] [PATCH] ocfs2: Remove some redundant casting George Spelvin
@ 2014-05-14 2:51 ` Jeff Liu
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Liu @ 2014-05-14 2:51 UTC (permalink / raw)
To: ocfs2-devel
Tao's Oracle email address was obsolete.
On 05/10/2014 06:45 AM, George Spelvin wrote:
> 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*.
>
> Signed-off-by: George Spelvin <linux@horizon.com>
> ---
> Obviously, this makes zero difference to the generated code, but
> it's prettier.
Indeed :), the patch looks good to me.
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Thanks,
-Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-14 2:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-09 22:45 [Ocfs2-devel] [PATCH] ocfs2: Remove some redundant casting George Spelvin
2014-05-14 2:51 ` Jeff Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).