2014-06-26 18:43:05

by Himangi Saraogi

[permalink] [raw]
Subject: [PATCH] ecryptfs: Drop cast

This patch does away with casts on void * as they are unnecessary.

The following Coccinelle semantic patch was used for making the change:

@r@
expression x;
void* e;
type T;
identifier f;
@@

(
*((T *)e)
|
((T *)x)[...]
|
((T *)x)->f
|
- (T *)
e
)

Signed-off-by: Himangi Saraogi <[email protected]>
Acked-by: Julia Lawall <[email protected]>
---
fs/ecryptfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 4d6c7e4..5459792 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -53,7 +53,7 @@ static void unlock_dir(struct dentry *dir)

static int ecryptfs_inode_test(struct inode *inode, void *lower_inode)
{
- if (ecryptfs_inode_to_lower(inode) == (struct inode *)lower_inode)
+ if (ecryptfs_inode_to_lower(inode) == lower_inode)
return 1;
return 0;
}
--
1.9.1


2014-06-26 18:58:59

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] ecryptfs: Drop cast

On Fri, 2014-06-27 at 00:12 +0530, Himangi Saraogi wrote:
> This patch does away with casts on void * as they are unnecessary.
[]
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
[]
> @@ -53,7 +53,7 @@ static void unlock_dir(struct dentry *dir)
>
> static int ecryptfs_inode_test(struct inode *inode, void *lower_inode)
> {
> - if (ecryptfs_inode_to_lower(inode) == (struct inode *)lower_inode)
> + if (ecryptfs_inode_to_lower(inode) == lower_inode)
> return 1;
> return 0;
> }

True, but perhaps this should be

{
return ecryptfs_inode_to_lower(inode) == lower_inode;
}