Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752369AbZL1RJJ (ORCPT ); Mon, 28 Dec 2009 12:09:09 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752146AbZL1RJH (ORCPT ); Mon, 28 Dec 2009 12:09:07 -0500 Received: from exprod6og112.obsmtp.com ([64.18.1.29]:50760 "HELO exprod6og112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751894AbZL1RJG convert rfc822-to-8bit (ORCPT ); Mon, 28 Dec 2009 12:09:06 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Subject: RE: [PATCH 1/5] arch/arm: Correct NULL test Date: Mon, 28 Dec 2009 12:09:04 -0500 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH 1/5] arch/arm: Correct NULL test Thread-Index: AcqH3ftdfh8otKYeSvuF1bUQbDYOIQAAkr+A References: <20091227215106.GA18317@pengutronix.de> From: "H Hartley Sweeten" To: "Julia Lawall" Cc: =?iso-8859-1?Q?Uwe_Kleine-K=F6nig?= , , , , X-OriginalArrivalTime: 28 Dec 2009 17:09:04.0488 (UTC) FILETIME=[755C2E80:01CA87E0] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1525 Lines: 46 On Monday, December 28, 2009 9:51 AM, Julia Lawall wrote: > On Mon, 28 Dec 2009, H Hartley Sweeten wrote: > >> On Sunday, December 27, 2009 3:08 PM, Julia Lawall wrote: >>>>> dbgfs_chan = kmalloc(sizeof(*dbgfs_state) * num_dma_channels, >>>>> GFP_KERNEL); >>>>> - if (!dbgfs_state) >>>>> + if (!dbgfs_chan) >>>>> goto err_alloc; >>>> Shouldn't the malloc line read: >>>> >>>> ... = kmalloc(sizeof(*dbgfs_chan) * ...) >>>> ^^^^^^^^^^ >>>> >>>> ? >>> >>> Good point, thanks. I will send a revised patch. >> >> Wouldn't this be clearer? >> >> ... = kmalloc(sizeof(struct dentry) * ...) > > Documentation/CodingStyle thinks otherwise: > > "The preferred form for passing a size of a struct is the following: > > p = kmalloc(sizeof(*p), ...); > > The alternative form where struct name is spelled out hurts readability > and introduces an opportunity for a bug when the pointer variable type is > changed but the corresponding sizeof that is passed to a memory allocator > is not." > > And actually, in this case, sizeof(struct dentry) would be wrong, because > the type of dbgfs_chan is struct dentry **, not struct dentry *. What is > wanted is an array of pointers. Ah, missed that. Thanks for pointing it out. Regards, Hartley -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/