Date: Mon, 23 Mar 2015 20:00:36 +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-10@freebsd.org Subject: svn commit: r280396 - stable/10/lib/msun/src Message-ID: <201503232000.t2NK0ave071391@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Mon Mar 23 20:00:35 2015 New Revision: 280396 URL: https://svnweb.freebsd.org/changeset/base/280396 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/10/lib/msun/src/s_scalbln.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/msun/src/s_scalbln.c ============================================================================== --- stable/10/lib/msun/src/s_scalbln.c Mon Mar 23 19:53:37 2015 (r280395) +++ stable/10/lib/msun/src/s_scalbln.c Mon Mar 23 20:00:35 2015 (r280396) @@ -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?201503232000.t2NK0ave071391>