[PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.
Rolf Eike Beer
eike-kernel at sf-tec.de
Fri Jul 21 07:12:25 EDT 2006
Panagiotis Issaris wrote:
> > > @@ -443,12 +442,11 @@ int con_clear_unimap(struct vc_data *vc,
> > > p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
> > > if (p && p->readonly) return -EIO;
> > > if (!p || --p->refcount) {
> > > - q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL);
> > > + q = kzalloc(sizeof(*p), GFP_KERNEL);
> > > if (!q) {
> > > if (p) p->refcount++;
> > > return -ENOMEM;
> > > }
> > > - memset(q, 0, sizeof(*q));
> > > q->refcount=1;
> > > *vc->vc_uni_pagedir_loc = (unsigned long)q;
> > > } else {
> >
> > This one still changes the way the code works. Before your patch *p will
> > be always zeroed out. Now if p is there before it will keep it's
> > contents.
>
> Hmm. I do not really see the functional change here: If the memory
> allocation failed, then in both cases, q will be zero and the function
> will return. If the memory allocation succeeds, then in both cases a
> memset will occur. Is it more subtle than that?
You're right, I got somehow confused by this p and q stuff.
Eike
More information about the linux-pcmcia
mailing list