Date: Mon, 23 Mar 2015 20:02:16 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r280397 - stable/9/lib/msun/src Message-ID: <201503232002.t2NK2Gi6072734@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Mon Mar 23 20:02:16 2015 New Revision: 280397 URL: https://svnweb.freebsd.org/changeset/base/280397 Log: MFC r277948: msun: use previously ignored "in" value. This fixes evaluation of exceptional values in scalblnl(). While here, simplify the code as suggested by Bruce Evans. Reported by: clang static analyzer Modified: stable/9/lib/msun/src/s_scalbln.c Directory Properties: stable/9/lib/msun/ (props changed) Modified: stable/9/lib/msun/src/s_scalbln.c ============================================================================== --- stable/9/lib/msun/src/s_scalbln.c Mon Mar 23 20:00:35 2015 (r280396) +++ stable/9/lib/msun/src/s_scalbln.c Mon Mar 23 20:02:16 2015 (r280397) @@ -35,13 +35,7 @@ scalbln (double x, long n) { int in; - in = (int)n; - if (in != n) { - if (n > 0) - in = INT_MAX; - else - in = INT_MIN; - } + in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; return (scalbn(x, in)); } @@ -50,13 +44,7 @@ scalblnf (float x, long n) { int in; - in = (int)n; - if (in != n) { - if (n > 0) - in = INT_MAX; - else - in = INT_MIN; - } + in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; return (scalbnf(x, in)); } @@ -65,12 +53,6 @@ scalblnl (long double x, long n) { int in; - in = (int)n; - if (in != n) { - if (n > 0) - in = INT_MAX; - else - in = INT_MIN; - } - return (scalbnl(x, (int)n)); + in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; + return (scalbnl(x, in)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503232002.t2NK2Gi6072734>