Received: from eggs.gnu.org ([2001:4830:134:3::10]:48258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XotnE-0002lZ-Lb for qemu-devel@nongnu.org; Thu, 13 Nov 2014 07:46:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xotn8-0004Nj-IG for qemu-devel@nongnu.org; Thu, 13 Nov 2014 07:46:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xotn8-0004Nb-B8 for qemu-devel@nongnu.org; Thu, 13 Nov 2014 07:46:26 -0500 From: Markus Armbruster References: <20141113112009.GL7462@stefanha-thinkpad.redhat.com> Date: Thu, 13 Nov 2014 13:46:18 +0100 In-Reply-To: <20141113112009.GL7462@stefanha-thinkpad.redhat.com> (Stefan Hajnoczi's message of "Thu, 13 Nov 2014 11:20:09 +0000") Message-ID: <877fyzclph.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/1] block migration: fix return value mismatch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Gary Hook , "qemu-devel@nongnu.org" Stefan Hajnoczi writes: > On Wed, Nov 12, 2014 at 06:48:18PM +0000, Gary Hook wrote: >> - return qemu_ftell(f) - last_ftell; >> + delta_ftell = qemu_ftell(f) - last_ftell; >> + return( (delta_ftell > 0) ? 1 : (delta_ftell < 0) ? -1 : 0 ); > > Good find! > > Please don't nest the ternary operator, it is hard to read. > > if (delta_ftell < 0) { > return -1; > } else if (delta_ftell > 0) { > return 1; > } else { > return 0; > } Bah, that's for wimps ;) return (delta_ftell > 0) - (delta_ftell < 0); Look ma, no branches!