All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntfs: Drop cast
@ 2014-06-28 13:33 Himangi Saraogi
  2014-06-29  0:30 ` Anton Altaparmakov
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-06-28 13:33 UTC (permalink / raw)
  To: Anton Altaparmakov, linux-ntfs-dev, linux-kernel; +Cc: julia.lawall

This patch removes the cast on data of type void * as it is not needed.
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>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 fs/ntfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index f47af5e..b3c55fc 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1817,7 +1817,7 @@ int ntfs_read_inode_mount(struct inode *vi)
 	i = vol->mft_record_size;
 	if (i < sb->s_blocksize)
 		i = sb->s_blocksize;
-	m = (MFT_RECORD*)ntfs_malloc_nofs(i);
+	m = ntfs_malloc_nofs(i);
 	if (!m) {
 		ntfs_error(sb, "Failed to allocate buffer for $MFT record 0.");
 		goto err_out;
-- 
1.9.1


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

* Re: [PATCH] ntfs: Drop cast
  2014-06-28 13:33 [PATCH] ntfs: Drop cast Himangi Saraogi
@ 2014-06-29  0:30 ` Anton Altaparmakov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Altaparmakov @ 2014-06-29  0:30 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-ntfs-dev, linux-kernel, julia.lawall

Hi,

Thanks for your patch.  Your patch is obviously correct however I actually prefer to have the type casts in place because it clearly shows what the variable type being assigned to is so I find it makes the code more readable to cast void pointers to the target variable type so I don't have to go and look up the type higher up.  Having said that I don't feel that strongly about it so I have no real objection to the patch getting applied...

Best regards,

	Anton

On 28 Jun 2014, at 14:33, Himangi Saraogi <himangi774@gmail.com> wrote:

> This patch removes the cast on data of type void * as it is not needed.
> 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>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> fs/ntfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
> index f47af5e..b3c55fc 100644
> --- a/fs/ntfs/inode.c
> +++ b/fs/ntfs/inode.c
> @@ -1817,7 +1817,7 @@ int ntfs_read_inode_mount(struct inode *vi)
> 	i = vol->mft_record_size;
> 	if (i < sb->s_blocksize)
> 		i = sb->s_blocksize;
> -	m = (MFT_RECORD*)ntfs_malloc_nofs(i);
> +	m = ntfs_malloc_nofs(i);
> 	if (!m) {
> 		ntfs_error(sb, "Failed to allocate buffer for $MFT record 0.");
> 		goto err_out;

-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
University of Cambridge Information Services, Roger Needham Building
7 JJ Thomson Avenue, Cambridge, CB3 0RB, UK


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

end of thread, other threads:[~2014-06-29  0:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-28 13:33 [PATCH] ntfs: Drop cast Himangi Saraogi
2014-06-29  0:30 ` Anton Altaparmakov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.