From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43146 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q75kR-0001Ep-52 for qemu-devel@nongnu.org; Tue, 05 Apr 2011 08:52:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q75kQ-0003cA-1Y for qemu-devel@nongnu.org; Tue, 05 Apr 2011 08:52:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q75kP-0003bE-OI for qemu-devel@nongnu.org; Tue, 05 Apr 2011 08:52:41 -0400 Message-ID: <4D9B1122.5070804@redhat.com> Date: Tue, 05 Apr 2011 14:54:58 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Fix integer overflow in block migration bandwidth calculation References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avishay Traeger Cc: qemu-devel@nongnu.org, Liran Schour Am 31.03.2011 15:52, schrieb Avishay Traeger: > > block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a > negative number, resulting in a negative bandwidth (running on a 32-bit > machine). Cast to avoid. > > Signed-off-by: Avishay Traeger This patch is corrupted by line wraps. > --- > block-migration.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/block-migration.c b/block-migration.c > index 8218bac..ffc92ee 100644 > --- a/block-migration.c > +++ b/block-migration.c > @@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time) > static inline long double compute_read_bwidth(void) > { > assert(block_mig_state.total_time != 0); > - return (block_mig_state.reads * BLOCK_SIZE)/ > block_mig_state.total_time; > + return ((long long)block_mig_state.reads * BLOCK_SIZE)/ > block_mig_state.total_time; This line exceeds 80 characters. While you're at it, you could add a space before the / Kevin