public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: "Robert P. J. Day" <rpjday@mindspring.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Jesper Juhl <jesper.juhl@gmail.com>,
	linux-mtd@lists.infradead.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
Date: Sun, 26 Aug 2007 15:28:56 +0100	[thread overview]
Message-ID: <200708261528.56250.vda.linux@googlemail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0708252021070.8721@localhost.localdomain>

On Sunday 26 August 2007 01:23, Robert P. J. Day wrote:
> On Sun, 26 Aug 2007, Jesper Juhl wrote:
> > On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
> > > i was thinking more along the lines of
> > >
> > > msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);
> > >
> > > which was kind of the obvious implication, no?
> >
> > I guess
> >
> > > unless there's a reason kcalloc() wouldn't work here, this is
> > > pretty much what kcalloc() was designed for.
> >
> > When Denys brought up the zeroing thing and mentioned kzalloc() I
> > did consider kcalloc() instead, but kzalloc() makes this allocation
> > nicely look like the preceding ones visually and I couldn't convince
> > myself that kcalloc() would give us any real benefit here.
> >
> > What exactely would using kcalloc() over kzalloc() here buy us?
>
> technically, nothing.

The idea of calloc is that it can check for underflow in parameter.

calloc(-1, 10000000) => easy to detect
malloc(-1 * 10000000) => malloc(-10000000) => not so trivial
--
vda

  parent reply	other threads:[~2007-08-26 14:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl@gmail.com>
2007-08-23 23:50 ` [PATCH 07/30] mtd: Get rid of pointless cast of kzalloc() return value in AT26xxx driver Jesper Juhl
2007-08-23 23:51 ` [PATCH 08/30] mtd: Avoid a pointless kmalloc() return value cast in TQM8xxL mapping handling code Jesper Juhl
2007-08-23 23:52 ` [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c Jesper Juhl
2007-08-24 10:41   ` Denys Vlasenko
2007-08-24 10:43     ` Robert P. J. Day
2007-08-25 22:27       ` Jesper Juhl
2007-08-25 23:59         ` Robert P. J. Day
2007-08-26  0:28           ` Jesper Juhl
2007-08-26  0:23             ` Robert P. J. Day
2007-08-26  0:36               ` Jesper Juhl
2007-08-26  1:52                 ` Kyle Moffett
2007-08-26 14:28               ` Denys Vlasenko [this message]
2007-08-26 14:37                 ` Jan Engelhardt
2007-08-26 22:10                   ` Jesper Juhl
2007-08-24 10:48     ` Jesper Juhl

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=200708261528.56250.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=dwmw2@infradead.org \
    --cc=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=rpjday@mindspring.com \
    /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