From 34da05b30d4947b54c1aafb2dbca8e91f58afaf0 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Tue, 19 Apr 2016 16:21:08 -0400
Subject: [PATCH] Fixes signed integer overlof in silk_ADD_POS_SAT32()

Removes unused 64-bit version
---
 silk/MacroCount.h  | 8 --------
 silk/MacroDebug.h  | 3 +--
 silk/SigProc_FIX.h | 3 +--
 3 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/silk/MacroCount.h b/silk/MacroCount.h
index 834817d05..54dbdbd98 100644
--- a/silk/MacroCount.h
+++ b/silk/MacroCount.h
@@ -319,14 +319,6 @@ static OPUS_INLINE opus_int32 silk_ADD_POS_SAT32(opus_int64 a, opus_int64 b){
     return(tmp);
 }
 
-#undef silk_ADD_POS_SAT64
-static OPUS_INLINE opus_int64 silk_ADD_POS_SAT64(opus_int64 a, opus_int64 b){
-    opus_int64 tmp;
-    ops_count += 1;
-    tmp = ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)));
-    return(tmp);
-}
-
 #undef    silk_LSHIFT8
 static OPUS_INLINE opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
     opus_int8 ret;
diff --git a/silk/MacroDebug.h b/silk/MacroDebug.h
index 35aedc5c5..8dd4ce2ee 100644
--- a/silk/MacroDebug.h
+++ b/silk/MacroDebug.h
@@ -539,8 +539,7 @@ static OPUS_INLINE opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, cha
    no checking needed for silk_POS_SAT32
    no checking needed for silk_ADD_POS_SAT8
    no checking needed for silk_ADD_POS_SAT16
-   no checking needed for silk_ADD_POS_SAT32
-   no checking needed for silk_ADD_POS_SAT64 */
+   no checking needed for silk_ADD_POS_SAT32 */
 
 #undef silk_LSHIFT8
 #define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__)
diff --git a/silk/SigProc_FIX.h b/silk/SigProc_FIX.h
index b63299441..3d3161c97 100644
--- a/silk/SigProc_FIX.h
+++ b/silk/SigProc_FIX.h
@@ -471,8 +471,7 @@ static OPUS_INLINE opus_int32 silk_ROR32( opus_int32 a32, opus_int rot )
 /* Add with saturation for positive input values */
 #define silk_ADD_POS_SAT8(a, b)             ((((a)+(b)) & 0x80)                 ? silk_int8_MAX  : ((a)+(b)))
 #define silk_ADD_POS_SAT16(a, b)            ((((a)+(b)) & 0x8000)               ? silk_int16_MAX : ((a)+(b)))
-#define silk_ADD_POS_SAT32(a, b)            ((((a)+(b)) & 0x80000000)           ? silk_int32_MAX : ((a)+(b)))
-#define silk_ADD_POS_SAT64(a, b)            ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)))
+#define silk_ADD_POS_SAT32(a, b)            ((((opus_uint32)(a)+(opus_uint32)(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
 
 #define silk_LSHIFT8(a, shift)              ((opus_int8)((opus_uint8)(a)<<(shift)))         /* shift >= 0, shift < 8  */
 #define silk_LSHIFT16(a, shift)             ((opus_int16)((opus_uint16)(a)<<(shift)))       /* shift >= 0, shift < 16 */
-- 
GitLab