From: Akihiko Odaki <[email protected]>

When !defined(SIGNED), nv - HALF will wrap around if nv < HALF because
nv and HALF are unsigned. Fix it by casting nv to mixeng_real, which is
signed.

Signed-off-by: Akihiko Odaki <[email protected]>
Acked-by: Marc-AndrĂ© Lureau <[email protected]>
Message-Id: <[email protected]>
---
 audio/mixeng_template.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h
index bc8509e423f..881653c44bf 100644
--- a/audio/mixeng_template.h
+++ b/audio/mixeng_template.h
@@ -43,13 +43,13 @@ static inline mixeng_real glue (conv_, ET) (IN_T v)
 #ifdef SIGNED
     return nv * (2.f / ((mixeng_real)IN_MAX - IN_MIN));
 #else
-    return (nv - HALF) * (2.f / (mixeng_real)IN_MAX);
+    return ((mixeng_real)nv - HALF) * (2.f / (mixeng_real)IN_MAX);
 #endif
 #else  /* !RECIPROCAL */
 #ifdef SIGNED
     return nv / (((mixeng_real)IN_MAX - IN_MIN) / 2.f);
 #else
-    return (nv - HALF) / ((mixeng_real)IN_MAX / 2.f);
+    return ((mixeng_real)nv - HALF) / ((mixeng_real)IN_MAX / 2.f);
 #endif
 #endif
 }
-- 
2.54.0


Reply via email to