svn commit: r278154 - head/lib/msun/src

Pedro F. Giffuni pfg at FreeBSD.org
Tue Feb 3 14:17:31 UTC 2015


Author: pfg
Date: Tue Feb  3 14:17:29 2015
New Revision: 278154
URL: https://svnweb.freebsd.org/changeset/base/278154

Log:
  Reduce confusion in scalbnl() family of functions.
  
  The changes unrelated to the bug in r277948 made
  the code very difficult to understand to both
  coverity and regular humans so take a step back
  to something that is much easier to understand
  for both and follows better the original code.
  
  CID:	1267992, 1267993, 1267994
  Discussed with:	kargl

Modified:
  head/lib/msun/src/s_scalbln.c

Modified: head/lib/msun/src/s_scalbln.c
==============================================================================
--- head/lib/msun/src/s_scalbln.c	Tue Feb  3 13:45:06 2015	(r278153)
+++ head/lib/msun/src/s_scalbln.c	Tue Feb  3 14:17:29 2015	(r278154)
@@ -35,7 +35,9 @@ scalbln (double x, long n)
 {
 	int in;
 
-	in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n;
+	in = (int)n;
+	if (in != n)
+		in = (n > 0) ? INT_MAX: INT_MIN;
 	return (scalbn(x, in));
 }
 
@@ -44,7 +46,9 @@ scalblnf (float x, long n)
 {
 	int in;
 
-	in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n;
+	in = (int)n;
+	if (in != n)
+		in = (n > 0) ? INT_MAX: INT_MIN;
 	return (scalbnf(x, in));
 }
 
@@ -53,6 +57,9 @@ scalblnl (long double x, long n)
 {
 	int in;
 
-	in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; 
+	in = (int)n;
+	if (in != n) {
+		in = (n > 0) ? INT_MAX: INT_MIN;
+	}
 	return (scalbnl(x, in));
 }


More information about the svn-src-head mailing list