From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [195.92.253.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6C566DDF4C for ; Wed, 10 Dec 2008 21:17:54 +1100 (EST) Date: Wed, 10 Dec 2008 10:17:45 +0000 From: Al Viro To: Yuri Tikhonov Subject: Re: [PATCH] fork_init: fix division by zero Message-ID: <20081210101745.GG28946@ZenIV.linux.org.uk> References: <200812092044.40649.yur@emcraft.com> <503391615.20081210130113@emcraft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <503391615.20081210130113@emcraft.com> Sender: Al Viro Cc: Wolfgang Denk , Detlev Zundel , linux-kernel@vger.kernel.org, Milton Miller , linuxppc-dev@ozlabs.org, Geert Uytterhoeven , Ilya Yanok List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, Dec 10, 2008 at 01:01:13PM +0300, Yuri Tikhonov wrote: > >> + max_threads = mempages * PAGE_SIZE / (8 * THREAD_SIZE); > > ^^^^^^^^^^^^^^^^^^^^ > >> +#endif > > > Can't this overflow, e.g. on 32-bit machines with HIGHMEM? > > The multiplier here is not PAGE_SIZE, but [PAGE_SIZE / (8 * > THREAD_SIZE)], and this value is expected to be rather small (2, 4, or > so). x * y / z is parsed as (x * y) / z, not x * (y / z). Only assignment operators (and ?:, in a sense that a ? b : c ? d : e is parsed as a ? b : (c ? d : e)) are right-to-left. The rest is left-to-right.