Received: from eggs.gnu.org ([140.186.70.92]:42815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRTi8-0001KS-3K for qemu-devel@nongnu.org; Tue, 31 May 2011 14:30:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRTi4-0001MX-SD for qemu-devel@nongnu.org; Tue, 31 May 2011 14:30:34 -0400 Received: from fe02x03-cgp.akado.ru ([77.232.31.165]:63822 helo=akado.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRTi4-0001L1-6X for qemu-devel@nongnu.org; Tue, 31 May 2011 14:30:32 -0400 Date: Tue, 31 May 2011 22:30:22 +0400 (MSD) From: malc In-Reply-To: <1306862938-13431-1-git-send-email-peter.maydell@linaro.org> Message-ID: References: <1306862938-13431-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH] audio: fix integer overflow expression List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: =?ISO-8859-15?Q?Andreas_F=E4rber?= , =?ISO-8859-15?Q?Juha_Riihim=E4ki?= , qemu-devel@nongnu.org, patches@linaro.org On Tue, 31 May 2011, Peter Maydell wrote: > From: Juha Riihim?ki > > Fix an integer overflow that can happen for signed 32 bit types > when using FLOAT_MIXENG. (Note that at the moment this is only true > when using the MacOSX coreaudio audio driver.) > > Signed-off-by: Juha Riihim?ki > Reviewed-by: Peter Maydell > --- > I'm trying to get random patches out of my patch-stack and upstream. > This one looks "obviously correct" but it only kicks in for MacOSX > and coreaudio, and I don't have access to that platform to test myself, > so treat my reviewed-by accordingly. > > This has actually been posted here before, last year: > http://patchwork.ozlabs.org/patch/48703/ One nit, only one of the casts is really needed, pick one and i'll apply it. > > audio/mixeng_template.h | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h > index a2d0ef8..e01da0a 100644 > --- a/audio/mixeng_template.h > +++ b/audio/mixeng_template.h > @@ -46,7 +46,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v) > #endif > #else /* !RECIPROCAL */ > #ifdef SIGNED > - return nv / (mixeng_real) (IN_MAX - IN_MIN); > + return nv / (mixeng_real) ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN); > #else > return (nv - HALF) / (mixeng_real) IN_MAX; > #endif > @@ -63,7 +63,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v) > } > > #ifdef SIGNED > - return ENDIAN_CONVERT ((IN_T) (v * (IN_MAX - IN_MIN))); > + return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN))); > #else > return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF)); > #endif > -- mailto:av1474@comtv.ru