Skip to contentSkip to conversation

ecryptfs: Drop cast

PATCH In review Himangi Saraogi 2 participants 2 messages Jun 26, 2014 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ecryptfs: Drop cast

This patch does away with cast on void * and the if as it is 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
)

---
v2: remove the if statement

 fs/ecryptfs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/ecryptfs/inode.c +1 -3
index 4d6c7e4..e67f9f0 100644
@@ -53,9 +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)
-		return 1;
-	return 0;
+	return ecryptfs_inode_to_lower(inode) == lower_inode;
 }
 
 static int ecryptfs_inode_set(struct inode *inode, void *opaque)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Himangi Saraogi

This patch does away with cast on void * and the if as it is 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
)

Quoted 5 lines

---
v2: remove the if statement

 fs/ecryptfs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Thanks! This looks good to me. I'll take the patch from here.

Tyler

Quoted 19 lines
fs/ecryptfs/inode.c +1 -3
index 4d6c7e4..e67f9f0 100644
@@ -53,9 +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)
-		return 1;
-	return 0;
+	return ecryptfs_inode_to_lower(inode) == lower_inode;
 }
 
 static int ecryptfs_inode_set(struct inode *inode, void *opaque)
Signature · 1 line
1.9.1