fs: Convert kmalloc()+memset() combo to kzalloc().
Subsystems (2)
PATCH 1/1 fs: Convert kmalloc()+memset() combo to kzalloc().
Convert all obvious combinations of kmalloc()+memset() to singlekzalloc() in the fs/ directory.
---
binfmt_elf_fdpic.c | 3 +-- seq_file.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
fs/binfmt_elf_fdpic.c +1 -2
@@ -709,12 +709,11 @@ #endifreturn -ELIBBAD ; size =sizeof (*loadmap) + nloads *sizeof (*seg); - loadmap =kmalloc (size,GFP_KERNEL ); + loadmap =kzalloc (size,GFP_KERNEL );if (!loadmap)return -ENOMEM ; params->loadmap = loadmap; -memset (loadmap,0 , size); loadmap->version =ELF32_FDPIC_LOADMAP_VERSION ; loadmap->nsegs = nloads;
fs/seq_file.c +1 -2
@@ -31,12 +31,11 @@ int seq_open(struct file *file, struct sstruct seq_file *p = file->private_data;if (!p) { - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return -ENOMEM ; file->private_data = p; } -memset (p,0 ,sizeof (*p));mutex_init (&p->lock); p->op = op;
Alan
NAKfs/seq_file.c int seq_open(struct file *file, struct s · line 40
Quoted 10 lines
fs/seq_file.c +1
-2if (!p) { - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return -ENOMEM ; file->private_data = p; } -memset (p,0 ,sizeof (*p));mutex_init (&p->lock); p->op = op;
NAK
If p was already set (ie private data existed) the old code zeroed it, your code does not, but only zeroes the new stuff.
Alan
Quoted 14 lines · Alan
fs/seq_file.c int seq_open(struct file *file, struct s · line 40
Quoted 10 lines
fs/seq_file.c +1
-2if (!p) { - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return -ENOMEM ; file->private_data = p; } -memset (p,0 ,sizeof (*p));mutex_init (&p->lock); p->op = op;NAK
Quoted 2 lines
If p was already set (ie private data existed) the old code zeroed it, your code does not, but only zeroes the new stuff.
whoops, sorry, my bad.
rday
Quoted 2 lines · Robert P. J. Day
Convert all obvious combinations of kmalloc()+memset() to single
kzalloc()in thefs/directory.
[snip]
Quoted 7 lines
fs/seq_file.c +0
-0@@ -31,12 +31,11 @@ int seq_open(struct file *file, struct sstruct seq_file *p = file->private_data;
fs/seq_file.c int seq_open(struct file *file, struct s · line 40
Quoted 10 lines
fs/seq_file.c +1
-2if (!p) { - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return -ENOMEM ; file->private_data = p; } -memset (p,0 ,sizeof (*p));mutex_init (&p->lock); p->op = op;
It's not the same! Previous erases it every time seq_open is called and after your change only once -- when p == NULL.
regards,
Signature · 4 lines
http://www.fi.muni.cz/~xslaby/ Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E