Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932288AbWCTNQq (ORCPT ); Mon, 20 Mar 2006 08:16:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932291AbWCTNQq (ORCPT ); Mon, 20 Mar 2006 08:16:46 -0500 Received: from courier.cs.helsinki.fi ([128.214.9.1]:18612 "EHLO mail.cs.helsinki.fi") by vger.kernel.org with ESMTP id S932288AbWCTNQp (ORCPT ); Mon, 20 Mar 2006 08:16:45 -0500 Date: Mon, 20 Mar 2006 15:16:18 +0200 (EET) From: Pekka J Enberg To: Denis Vlasenko cc: Oliver Neukum , Arjan van de Ven , Matthew Wilcox , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH]use kzalloc in vfs where appropriate In-Reply-To: <200603201508.47960.vda@ilport.com.ua> Message-ID: References: <200603192150.23444.oliver@neukum.org> <84144f020603192325h54fd3212l1f4846fd40b9f074@mail.gmail.com> <200603201508.47960.vda@ilport.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 912 Lines: 27 On Monday 20 March 2006 09:25, Pekka Enberg wrote: > > > Rewriting the test as: > > > n!=0 && n > INT_MAX / size > > > saves the division because size is much likelier to be a constant, and indeed > > > the code is better: > > > > > > cmpq $268435455, %rax > > > movq $0, 40(%rsp) > > > ja .L313 > > > > > > Is there anything I am missing? On Mon, 20 Mar 2006, Denis Vlasenko wrote: > You may drop "n!=0" part, but you must check size!=0. > Since if size is 0, kcalloc returns NULL, then > > if (!size || n > INT_MAX / size) > return NULL; Uh, oh, I must be getting blind to have missed that... Pekka - 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/