* [Qemu-devel] [PATCH v2] audio: fix integer overflow expression
@ 2011-05-31 18:40 Peter Maydell
2011-05-31 19:14 ` Andreas Färber
2011-05-31 20:14 ` malc
0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2011-05-31 18:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Juha Riihimäki, Andreas Färber, patches
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] audio: fix integer overflow expression
2011-05-31 18:40 [Qemu-devel] [PATCH v2] audio: fix integer overflow expression Peter Maydell
@ 2011-05-31 19:14 ` Andreas Färber
2011-05-31 20:14 ` malc
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2011-05-31 19:14 UTC (permalink / raw)
To: Peter Maydell, malc; +Cc: Juha Riihimäki, QEMU Developers, patches
Am 31.05.2011 um 20:40 schrieb Peter Maydell:
> 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>
Tested-by: Andreas Färber <andreas.faerber@web.de>
Silences the warnings for me.
Thanks,
Andreas
> ---
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] audio: fix integer overflow expression
2011-05-31 18:40 [Qemu-devel] [PATCH v2] audio: fix integer overflow expression Peter Maydell
2011-05-31 19:14 ` Andreas Färber
@ 2011-05-31 20:14 ` malc
1 sibling, 0 replies; 3+ messages in thread
From: malc @ 2011-05-31 20:14 UTC (permalink / raw)
To: Peter Maydell
Cc: Andreas Färber, Juha Riihimäki, qemu-devel, patches
On Tue, 31 May 2011, Peter Maydell wrote:
> 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.
Applied with minor stylistic change, thanks to all involved.
[..snip..]
--
mailto:av1474@comtv.ru
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-31 20:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 18:40 [Qemu-devel] [PATCH v2] audio: fix integer overflow expression Peter Maydell
2011-05-31 19:14 ` Andreas Färber
2011-05-31 20:14 ` malc
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).