Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932285AbWCTNI6 (ORCPT ); Mon, 20 Mar 2006 08:08:58 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932284AbWCTNI6 (ORCPT ); Mon, 20 Mar 2006 08:08:58 -0500 Received: from 167.imtp.Ilyichevsk.Odessa.UA ([195.66.192.167]:12257 "HELO ilport.com.ua") by vger.kernel.org with SMTP id S932285AbWCTNI5 (ORCPT ); Mon, 20 Mar 2006 08:08:57 -0500 From: Denis Vlasenko To: "Pekka Enberg" Subject: Re: [PATCH]use kzalloc in vfs where appropriate Date: Mon, 20 Mar 2006 15:08:47 +0200 User-Agent: KMail/1.8.2 Cc: "Oliver Neukum" , "Arjan van de Ven" , "Matthew Wilcox" , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <200603192150.23444.oliver@neukum.org> <84144f020603192325h54fd3212l1f4846fd40b9f074@mail.gmail.com> In-Reply-To: <84144f020603192325h54fd3212l1f4846fd40b9f074@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200603201508.47960.vda@ilport.com.ua> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 780 Lines: 25 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? 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; -- vda - 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/