Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Markus Elfring and committed by
Theodore Ts'o
d695a1be 1bd8d6cd

+2 -2
+1 -1
fs/ext4/dir.c
··· 411 411 { 412 412 struct dir_private_info *p; 413 413 414 - p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL); 414 + p = kzalloc(sizeof(*p), GFP_KERNEL); 415 415 if (!p) 416 416 return NULL; 417 417 p->curr_hash = pos2maj_hash(filp, pos);
+1 -1
fs/ext4/mmp.c
··· 367 367 goto failed; 368 368 } 369 369 370 - mmpd_data = kmalloc(sizeof(struct mmpd_data), GFP_KERNEL); 370 + mmpd_data = kmalloc(sizeof(*mmpd_data), GFP_KERNEL); 371 371 if (!mmpd_data) { 372 372 ext4_warning(sb, "not enough memory for mmpd_data"); 373 373 goto failed;