Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755735AbaLVVfF (ORCPT ); Mon, 22 Dec 2014 16:35:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37467 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755715AbaLVVfD (ORCPT ); Mon, 22 Dec 2014 16:35:03 -0500 Date: Mon, 22 Dec 2014 13:35:01 -0800 From: Andrew Morton To: Fabian Frederick Cc: linux-kernel@vger.kernel.org, joe@perches.com, ocfs2-devel@oss.oracle.com, Mark Fasheh Subject: Re: [Ocfs2-devel] [PATCH 1/1 linux-next] ocfs2: remove unnecessary sizeof(char) Message-Id: <20141222133501.916a0944e5f0719e60e2c4eb@linux-foundation.org> In-Reply-To: <1419275109-11641-1-git-send-email-fabf@skynet.be> References: <1419275109-11641-1-git-send-email-fabf@skynet.be> X-Mailer: Sylpheed 3.4.0beta7 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Dec 2014 20:05:09 +0100 Fabian Frederick wrote: > sizeof(char) is always 1. > > ... > > --- a/fs/ocfs2/journal.c > +++ b/fs/ocfs2/journal.c > @@ -129,8 +129,8 @@ int ocfs2_compute_replay_slots(struct ocfs2_super *osb) > if (osb->replay_map) > return 0; > > - replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + > - (osb->max_slots * sizeof(char)), GFP_KERNEL); > + replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + osb->max_slots, > + GFP_KERNEL); > > if (!replay_map) { > mlog_errno(-ENOMEM); I dunno. The code at present isn't particularly idiomatic, but it has some documentation value and says "I know what I'm doing". It would be better if it was kzalloc(sizeof(struct ocfs2_replay_map) * sizeof(struct ocfs2_replay_map.rm_replay_slots[0]), ...); And it would be better if C permitted that ;) kzalloc(sizeof(struct ocfs2_replay_map) * sizeof((struct ocfs2_replay_map *)0)->rm_replay_slots[0]), ...); yuk. -- 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/