mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	Rolf Eike Beer <eike-kernel@sf-tec.de>,
	Panagiotis Issaris <takis@lumumba.uhasselt.be>,
	linux-kernel@vger.kernel.org, len.brown@intel.com,
	chas@cmf.nrl.navy.mil, miquel@df.uba.ar, kkeil@suse.de,
	benh@kernel.crashing.org, video4linux-list@redhat.com,
	rmk+mmc@arm.linux.org.uk, Neela.Kolli@engenio.com,
	vandrove@vc.cvut.cz, adaplas@pol.net, thomas@winischhofer.net,
	weissg@vienna.at, philb@gnu.org,
	linux-pcmcia@lists.infradead.org, jkmaline@cc.hut.fi,
	paulus@samba.org
Subject: Re: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.
Date: Fri, 21 Jul 2006 11:09:38 +0200	[thread overview]
Message-ID: <44C099D2.5030300@s5r6.in-berlin.de> (raw)
In-Reply-To: <44C07CB2.1040303@pobox.com>

Jeff Garzik wrote:
> Pekka Enberg wrote:
>> On 7/21/06, Rolf Eike Beer <eike-kernel@sf-tec.de> wrote:
>>> > -     if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
>>> > +     handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
>>> > +     if (!handle)
>>> >               return NULL;
>>>
>>> sizeof(*handle)?
>> 
>> In general, yes. However, some maintainers don't like that, so I would
>> recommend to keep them as-is unless you get a clear ack from the
>> maintainer to change it.

I suggest:
 - check if "sizeof(type)"->"sizeof(*ptr)" is correct
 - if yes, change it
 - do this for all kmalloc + kzalloc in a file you touched, or
   better yet for all kmalloc + kzalloc in a driver or subsystem you
   touched
Maintainers who don't agree can always post a NAK. There are hardly any
special cases which speak against that change --- provided the change is
done for the whole subsystem.

> Strongly agreed.  Follow the style of the existing code as closely as 
> possible, and resist the temptation of making little "improvements" 
> while you are doing a task...

The 2nd half of this statement is a good and important rule. But look at
this particular case. The patch does (or could) contain
 - consolidation of kmalloc+memset/0 -> kzalloc where correct,
 - better style of the size argument where correct,
 - whitespace style adjustments of the touched regions.
All of these changes, if done correct, are true improvements WRT
programming idioms. IMO it's a single task, therefore adheres to that
rule. I'd only split this kind of patches if separately maintained
subsystems are touched.

As for the 1st half of this statement, "follow the style of existing
code as closely as possible": This is problematic in light of the more
important rule "follow CodingStyle".

I suggest to follow existing style if small changes are introduced and
the existing code mostly complies to CodingStyle. If existing code with
small deviations from CodingStyle is touched, the potential loss of
readability by partial conversion to CodingStyle may be negligible. If
existing code with bigger deviations from CodingStyle is touched, the
author of a patch should consider to provide an additional patch before
or after that with a complete conversion to CodingStyle. (I took the
time to do this on a few occasions too.)
-- 
Stefan Richter
-=====-=-==- -=== =--==
http://arcgraph.de/sr/

  reply	other threads:[~2006-07-21  9:12 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-20 19:05 Panagiotis Issaris
2006-07-21  6:50 ` Rolf Eike Beer
2006-07-21  6:58   ` Pekka Enberg
2006-07-21  7:05     ` Jeff Garzik
2006-07-21  9:09       ` Stefan Richter [this message]
2006-07-21 10:20         ` Jesper Juhl
2006-07-21 10:35           ` Panagiotis Issaris
2006-07-21 10:38             ` Pekka J Enberg
2006-07-21 10:55               ` Stefan Richter
2006-07-22 17:58                 ` Tomasz Kłoczko
2006-07-22 18:25                   ` Stefan Richter
2006-07-22 18:35                     ` Tomasz Kłoczko
2006-07-22 20:02                       ` Jeff Garzik
2006-07-22 20:55                         ` Tomasz Kłoczko
2006-07-23 11:20                           ` Alexey Dobriyan
2006-07-23 17:55                             ` Tomasz Kłoczko
2006-07-23 18:24                               ` Michael Buesch
2006-07-24  0:10                                 ` Tomasz Kłoczko
2006-07-24  0:49                                   ` Tomasz Kłoczko
2006-07-24  8:03                                     ` Lindent cleanup (was Re: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.) Stefan Richter
2006-07-24  8:52                                       ` Tomasz Kłoczko
2006-07-23 15:16                         ` [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc Stefan Richter
2006-07-23 18:09                           ` Tomasz Kłoczko
2006-07-21 10:53           ` Stefan Richter
2006-07-21 11:09             ` Stefan Richter
2006-07-21 21:16           ` Jeff Garzik
2006-07-21 21:15         ` Jeff Garzik
2006-07-22  6:20           ` Stefan Richter
2006-07-21  9:32       ` [PATCH] drivers: Conversions from kmalloc+memset tok(z|c)alloc Panagiotis Issaris
2006-07-21 10:14         ` Pekka J Enberg
2006-07-21 10:42           ` Panagiotis Issaris
2006-07-21 11:02           ` Stefan Richter
2006-07-21 11:20             ` Pekka J Enberg
2006-07-21 14:08               ` Stefan Richter
2006-07-21 21:17           ` Jeff Garzik
2006-07-21 10:21   ` [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc Daniel K.
2006-07-21 10:30   ` Panagiotis Issaris
2006-07-21 11:12     ` Rolf Eike Beer
2006-07-21 12:35 ` Dmitry Torokhov
2006-07-21 12:39   ` Panagiotis Issaris
  -- strict thread matches above, loose matches on Subject: below --
2006-07-22  2:22 Brown, Len
2006-07-19  0:46 Panagiotis Issaris
2006-07-19  0:59 ` Alexey Dobriyan
2006-07-19  1:38   ` Panagiotis Issaris
2006-07-19  2:40 ` Daniel K.
2006-07-19  8:38   ` Pekka Enberg
2006-07-20 17:25   ` Panagiotis Issaris
2006-07-19 12:17 ` Antonino A. Daplas
2006-07-19 12:52 ` Paul Mackerras
2006-07-19 13:53   ` Pekka Enberg
2006-07-19 13:53 ` Paulo Marques
2006-07-20 18:03   ` Panagiotis Issaris

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=44C099D2.5030300@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=Neela.Kolli@engenio.com \
    --cc=adaplas@pol.net \
    --cc=benh@kernel.crashing.org \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=eike-kernel@sf-tec.de \
    --cc=jgarzik@pobox.com \
    --cc=jkmaline@cc.hut.fi \
    --cc=kkeil@suse.de \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.org \
    --cc=miquel@df.uba.ar \
    --cc=paulus@samba.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=philb@gnu.org \
    --cc=rmk+mmc@arm.linux.org.uk \
    --cc=takis@lumumba.uhasselt.be \
    --cc=thomas@winischhofer.net \
    --cc=vandrove@vc.cvut.cz \
    --cc=video4linux-list@redhat.com \
    --cc=weissg@vienna.at \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®