* [Qemu-devel] [PATCH] audio: fix integer overflow expression
@ 2011-05-31 17:28 Peter Maydell
2011-05-31 18:24 ` Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peter Maydell @ 2011-05-31 17:28 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>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
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/
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
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] audio: fix integer overflow expression
2011-05-31 17:28 [Qemu-devel] [PATCH] audio: fix integer overflow expression Peter Maydell
@ 2011-05-31 18:24 ` Peter Maydell
2011-05-31 18:30 ` malc
2011-05-31 18:52 ` Andreas Färber
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2011-05-31 18:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Juha Riihimäki, patches
This definitely had malc on the cc list when I sent it; as far
as I can tell the mailing list server ate that cc...
-- PMM
On 31 May 2011 18:28, Peter Maydell <peter.maydell@linaro.org> 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>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> 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/
>
> 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
> --
> 1.7.1
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] audio: fix integer overflow expression
2011-05-31 17:28 [Qemu-devel] [PATCH] audio: fix integer overflow expression Peter Maydell
2011-05-31 18:24 ` Peter Maydell
@ 2011-05-31 18:30 ` malc
2011-05-31 18:52 ` Andreas Färber
2 siblings, 0 replies; 4+ messages in thread
From: malc @ 2011-05-31 18:30 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>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] audio: fix integer overflow expression
2011-05-31 17:28 [Qemu-devel] [PATCH] audio: fix integer overflow expression Peter Maydell
2011-05-31 18:24 ` Peter Maydell
2011-05-31 18:30 ` malc
@ 2011-05-31 18:52 ` Andreas Färber
2 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2011-05-31 18:52 UTC (permalink / raw)
To: Peter Maydell; +Cc: Juha Riihimäki, Riku Voipio, QEMU Developers, patches
Am 31.05.2011 um 19:28 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.)
>
Missing Riku's SoB compared to the link you gave below!
> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> 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.
The warnings I get on v10.5 ppc64 are as follows:
CC audio/mixeng.o
In file included from /Users/andreas/QEMU/qemu/audio/mixeng.c:112:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h: In function
‘conv_natural_int32_t’:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h:49: warning: integer
overflow in expression
/Users/andreas/QEMU/qemu/audio/mixeng_template.h: In function
‘clip_natural_int32_t’:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h:66: warning: integer
overflow in expression
In file included from /Users/andreas/QEMU/qemu/audio/mixeng.c:117:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h: In function
‘conv_swap_int32_t’:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h:49: warning: integer
overflow in expression
/Users/andreas/QEMU/qemu/audio/mixeng_template.h: In function
‘clip_swap_int32_t’:
/Users/andreas/QEMU/qemu/audio/mixeng_template.h:66: warning: integer
overflow in expression
I confirm that this patch silences these. Will test the new patch
right away.
> This has actually been posted here before, last year:
> http://patchwork.ozlabs.org/patch/48703/
That patch clearly shows that dumping a large and unrelated patch
series onto the mailing list without cc'ing people and never following
them up is not a winning strategy.
Andreas
> 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
> --
> 1.7.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-31 18:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 17:28 [Qemu-devel] [PATCH] audio: fix integer overflow expression Peter Maydell
2011-05-31 18:24 ` Peter Maydell
2011-05-31 18:30 ` malc
2011-05-31 18:52 ` Andreas Färber
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).