[asterisk-commits] seanbright: branch 1.8 r386929 - /branches/1.8/include/asterisk/utils.h

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 30 08:45:44 CDT 2013


Author: seanbright
Date: Tue Apr 30 08:45:40 2013
New Revision: 386929

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386929
Log:
Use the proper lower bound when doing saturation arithmetic.

16 bit signed integers have a range of [-32768, 32768).  The existing code
was using the interval (-32768, 32768) instead.  This patch fixes that.

Modified:
    branches/1.8/include/asterisk/utils.h

Modified: branches/1.8/include/asterisk/utils.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/utils.h?view=diff&rev=386929&r1=386928&r2=386929
==============================================================================
--- branches/1.8/include/asterisk/utils.h (original)
+++ branches/1.8/include/asterisk/utils.h Tue Apr 30 08:45:40 2013
@@ -307,8 +307,8 @@
 	res = (int) *input + *value;
 	if (res > 32767)
 		*input = 32767;
-	else if (res < -32767)
-		*input = -32767;
+	else if (res < -32768)
+		*input = -32768;
 	else
 		*input = (short) res;
 }
@@ -320,8 +320,8 @@
 	res = (int) *input - *value;
 	if (res > 32767)
 		*input = 32767;
-	else if (res < -32767)
-		*input = -32767;
+	else if (res < -32768)
+		*input = -32768;
 	else
 		*input = (short) res;
 }
@@ -333,8 +333,8 @@
 	res = (int) *input * *value;
 	if (res > 32767)
 		*input = 32767;
-	else if (res < -32767)
-		*input = -32767;
+	else if (res < -32768)
+		*input = -32768;
 	else
 		*input = (short) res;
 }




More information about the asterisk-commits mailing list