Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1715644 > unrolled thread

[PATCH 2/2] ext4: Improve a size determination in two functions

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-08-19 13:50 +0200
Last post2017-08-24 20:00 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] ext4: Improve a size determination in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-19 13:50 +0200
    Re: [PATCH 2/2] ext4: Improve a size determination in two functions Eric Sandeen <esandeen@redhat.com> - 2017-08-20 03:50 +0200
      Re: [PATCH 2/2] ext4: Improve a size determination in two functions Theodore Ts'o <tytso@mit.edu> - 2017-08-24 20:00 +0200

#1715644 — [PATCH 2/2] ext4: Improve a size determination in two functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-08-19 13:50 +0200
Subject[PATCH 2/2] ext4: Improve a size determination in two functions
Message-ID<ugaql-NZ-1@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 19 Aug 2017 13:14:26 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/dir.c | 2 +-
 fs/ext4/mmp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index e8b365000d73..b04e882179c6 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -411,7 +411,7 @@ static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
 {
 	struct dir_private_info *p;
 
-	p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
+	p = kzalloc(sizeof(*p), GFP_KERNEL);
 	if (!p)
 		return NULL;
 	p->curr_hash = pos2maj_hash(filp, pos);
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 1ce00453f612..3fa5df9f5573 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -367,5 +367,5 @@ int ext4_multi_mount_protect(struct super_block *sb,
 		goto failed;
 	}
 
-	mmpd_data = kmalloc(sizeof(struct mmpd_data), GFP_KERNEL);
+	mmpd_data = kmalloc(sizeof(*mmpd_data), GFP_KERNEL);
 	if (!mmpd_data)
-- 
2.14.0

[toc] | [next] | [standalone]


#1715788

FromEric Sandeen <esandeen@redhat.com>
Date2017-08-20 03:50 +0200
Message-ID<ugnxf-nG-7@gated-at.bofh.it>
In reply to#1715644
On 8/19/17 6:48 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 19 Aug 2017 13:14:26 +0200
> 
> Replace the specification of data structures by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks good,

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/ext4/dir.c | 2 +-
>  fs/ext4/mmp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> index e8b365000d73..b04e882179c6 100644
> --- a/fs/ext4/dir.c
> +++ b/fs/ext4/dir.c
> @@ -411,7 +411,7 @@ static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
>  {
>  	struct dir_private_info *p;
>  
> -	p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
> +	p = kzalloc(sizeof(*p), GFP_KERNEL);
>  	if (!p)
>  		return NULL;
>  	p->curr_hash = pos2maj_hash(filp, pos);
> diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
> index 1ce00453f612..3fa5df9f5573 100644
> --- a/fs/ext4/mmp.c
> +++ b/fs/ext4/mmp.c
> @@ -367,5 +367,5 @@ int ext4_multi_mount_protect(struct super_block *sb,
>  		goto failed;
>  	}
>  
> -	mmpd_data = kmalloc(sizeof(struct mmpd_data), GFP_KERNEL);
> +	mmpd_data = kmalloc(sizeof(*mmpd_data), GFP_KERNEL);
>  	if (!mmpd_data)
> 

[toc] | [prev] | [next] | [standalone]


#1719484

FromTheodore Ts'o <tytso@mit.edu>
Date2017-08-24 20:00 +0200
Message-ID<ui4Aa-1eO-19@gated-at.bofh.it>
In reply to#1715788
On Sat, Aug 19, 2017 at 08:49:20PM -0500, Eric Sandeen wrote:
> On 8/19/17 6:48 AM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 19 Aug 2017 13:14:26 +0200
> > 
> > Replace the specification of data structures by pointer dereferences
> > as the parameter for the operator "sizeof" to make the corresponding size
> > determination a bit safer according to the Linux coding style convention.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> Looks good,
> 
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>

Thanks, applied.

					- Ted

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web