Skip to content

Commit d695a1b

Browse files
elfringtytso
authored andcommitted
ext4: use sizeof(*ptr)
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> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
1 parent 1bd8d6c commit d695a1b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/ext4/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp,
411411
{
412412
struct dir_private_info *p;
413413

414-
p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
414+
p = kzalloc(sizeof(*p), GFP_KERNEL);
415415
if (!p)
416416
return NULL;
417417
p->curr_hash = pos2maj_hash(filp, pos);

‎fs/ext4/mmp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
367367
goto failed;
368368
}
369369

370-
mmpd_data = kmalloc(sizeof(struct mmpd_data), GFP_KERNEL);
370+
mmpd_data = kmalloc(sizeof(*mmpd_data), GFP_KERNEL);
371371
if (!mmpd_data) {
372372
ext4_warning(sb, "not enough memory for mmpd_data");
373373
goto failed;

0 commit comments

Comments
 (0)