From patchwork Tue May 31 18:40:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1686 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:54:23 -0000 Delivered-To: patches@linaro.org Received: by 10.52.110.9 with SMTP id hw9cs306483vdb; Tue, 31 May 2011 11:40:26 -0700 (PDT) Received: by 10.216.233.92 with SMTP id o70mr6227006weq.71.1306867226155; Tue, 31 May 2011 11:40:26 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id r60si746746wec.204.2011.05.31.11.40.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 May 2011 11:40:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QRTrZ-0003Wk-EM; Tue, 31 May 2011 19:40:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, malc , =?UTF-8?q?Juha=20Riihim=C3=A4ki?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2] audio: fix integer overflow expression Date: Tue, 31 May 2011 19:40:21 +0100 Message-Id: <1306867221-13535-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 MIME-Version: 1.0 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 [Peter Maydell: Removed unnecessary casts] Signed-off-by: Peter Maydell --- 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