qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Juha Riihimäki" <juha.riihimaki@nokia.com>,
	"Andreas Färber" <andreas.faerber@web.de>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH v2] audio: fix integer overflow expression
Date: Tue, 31 May 2011 19:40:21 +0100	[thread overview]
Message-ID: <1306867221-13535-1-git-send-email-peter.maydell@linaro.org> (raw)

From: Juha Riihimäki <juha.riihimaki@nokia.com>

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 <juha.riihimaki@nokia.com>
[Peter Maydell: Removed unnecessary casts]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
v1->v2 : as suggested by Malc, removed one unnecessary cast
from each change.

 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..a38055c 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 - 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 - IN_MIN)));
 #else
     return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF));
 #endif
-- 
1.7.1

             reply	other threads:[~2011-05-31 18:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 18:40 Peter Maydell [this message]
2011-05-31 19:14 ` [Qemu-devel] [PATCH v2] audio: fix integer overflow expression Andreas Färber
2011-05-31 20:14 ` malc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306867221-13535-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=andreas.faerber@web.de \
    --cc=juha.riihimaki@nokia.com \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).