add patch remove-useless-code-in-strtohash
[ext4-patch-queue.git] / use-sizeof-of-ptr
blobf597c2d188058c0b45ec43240d283c259198b36b
1 ext4: use sizeof(*ptr)
3 From: Markus Elfring <elfring@users.sourceforge.net>
5 Replace the specification of data structures by pointer dereferences
6 as the parameter for the operator "sizeof" to make the corresponding size
7 determination a bit safer according to the Linux coding style convention.
9 This issue was detected by using the Coccinelle software.
11 Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 Reviewed-by: Eric Sandeen <sandeen@redhat.com>
14 ---
15  fs/ext4/dir.c | 2 +-
16  fs/ext4/mmp.c | 2 +-
17  2 files changed, 2 insertions(+), 2 deletions(-)
19 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
20 index e8b365000d73..b04e882179c6 100644
21 --- a/fs/ext4/dir.c
22 +++ b/fs/ext4/dir.c
23 @@ -411,7 +411,7 @@ static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
24  {
25         struct dir_private_info *p;
27 -       p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
28 +       p = kzalloc(sizeof(*p), GFP_KERNEL);
29         if (!p)
30                 return NULL;
31         p->curr_hash = pos2maj_hash(filp, pos);
32 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
33 index eb9835638680..77cdce1f17ce 100644
34 --- a/fs/ext4/mmp.c
35 +++ b/fs/ext4/mmp.c
36 @@ -367,7 +367,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
37                 goto failed;
38         }
40 -       mmpd_data = kmalloc(sizeof(struct mmpd_data), GFP_KERNEL);
41 +       mmpd_data = kmalloc(sizeof(*mmpd_data), GFP_KERNEL);
42         if (!mmpd_data) {
43                 ext4_warning(sb, "not enough memory for mmpd_data");
44                 goto failed;