ecryptfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ecryptfs: Drop cast
@ 2014-06-26 19:41 Himangi Saraogi
  2014-06-26 19:50 ` Tyler Hicks
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-06-26 19:41 UTC (permalink / raw)
  To: Tyler Hicks, ecryptfs, linux-kernel; +Cc: julia.lawall, Joe Perches

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
)

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
v2: remove the if statement
 fs/ecryptfs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 4d6c7e4..e67f9f0 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -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)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ecryptfs: Drop cast
  2014-06-26 19:41 [PATCH v2] ecryptfs: Drop cast Himangi Saraogi
@ 2014-06-26 19:50 ` Tyler Hicks
  0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2014-06-26 19:50 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: ecryptfs, linux-kernel, julia.lawall, Joe Perches

[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]

On 2014-06-27 01:11:59, Himangi Saraogi wrote:
> 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
> )
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> ---
> 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

> 
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 4d6c7e4..e67f9f0 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -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)
> -- 
> 1.9.1
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-26 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 19:41 [PATCH v2] ecryptfs: Drop cast Himangi Saraogi
2014-06-26 19:50 ` Tyler Hicks

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).