From: Arnaldo Carvalho de Melo <acme@mandriva.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] kmalloc -> kzalloc conversion in Documentation
Date: Wed, 03 Jan 2007 11:37:55 +0000 [thread overview]
Message-ID: <20070103113755.GA3995@mandriva.com> (raw)
In-Reply-To: <20070102130813.GA7459@unknown-00-0d-60-79-ca-00.lan>
On Tue, Jan 02, 2007 at 10:39:01AM -0500, Robert P. J. Day wrote:
> On Tue, 2 Jan 2007, Thomas Hisch wrote:
>
> > On Tue, Jan 02, 2007 at 08:40:26AM -0500, Robert P. J. Day wrote:
>
> > > > strncpy(fw_priv->fw_id, fw_name, FIRMWARE_NAME_MAX);
> > > > fw_priv->fw_id[FIRMWARE_NAME_MAX-1] = '\0';
> > > > @@ -180,7 +178,7 @@ static int __init firmware_sample_init(void)
> > > > int error;
> > > >
> > > > device_initialize(&my_device);
> > > > - class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
> > > > + class_dev = kzalloc(sizeof(struct class_device), GFP_KERNEL);
> > > > if(!class_dev)
> > > > return -ENOMEM;
> > >
> > > this also seems inappropriate. the only kmalloc() calls that
> > > should be converted to kzalloc() calls are ones for which the
> > > allocated memory is set immediately to zero. that's not what's
> > > happening here, so you should leave the original kmalloc() call as
> > > it is.
> >
> > what is the drawback of changing above kmalloc calls to kzalloc?
>
> because you would be changing the actual logic of the code. a
> kmalloc() followed by a memset() to zero can reasonably be replaced by
> a single kzalloc() call since it effectively doesn't change the code
> logic.
>
> but replacing a kmalloc() by a kzalloc() definitely changes the
> underlying processing. it *might* not cause any problem whatsoever,
> but that's not the point. it simply doesn't represent the same code
> anymore, that's all. not better, not worse -- just different.
Worse, as it consumes more processor cycles, if one is allocating a
struct and initializing explicitely all its fields or just don't care
about what is the initial values that comes in the area kmalloc'ed the
memset is just that, contributing to global warming 8-)
- Arnaldo
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-01-03 11:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-02 13:08 [KJ] [PATCH] kmalloc -> kzalloc conversion in Documentation examples Thomas Hisch
2007-01-02 13:34 ` [KJ] [PATCH] kmalloc -> kzalloc conversion in Documentation Robert P. J. Day
2007-01-02 13:40 ` Robert P. J. Day
2007-01-02 14:17 ` Thomas Hisch
2007-01-02 15:39 ` Robert P. J. Day
2007-01-03 11:37 ` Arnaldo Carvalho de Melo [this message]
2007-01-05 15:16 ` Alexey Dobriyan
2007-01-05 15:28 ` Robert P. J. Day
2007-01-05 15:30 ` tom hisch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070103113755.GA3995@mandriva.com \
--to=acme@mandriva.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.