From: Martin Liska Date: Fri, 28 Apr 2017 12:51:22 +0000 (+0200) Subject: Fix format_gcov to not print misleading values (PR gcov-profile/53915) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=07ea19a797c6087725fe5b9f2630871c52020311;p=gcc.git Fix format_gcov to not print misleading values (PR gcov-profile/53915) 2017-04-28 Martin Liska PR gcov-profile/53915 * gcov.c (format_gcov): Print 'NAN %' when top > bottom. From-SVN: r247375 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 63b6276c07d..608e0e96dab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-04-28 Martin Liska + + PR gcov-profile/53915 + * gcov.c (format_gcov): Print 'NAN %' when top > bottom. + 2017-04-28 Martin Liska PR gcov-profile/79891 diff --git a/gcc/gcov.c b/gcc/gcov.c index b25464e730e..924a5a38164 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -1946,6 +1946,13 @@ format_gcov (gcov_type top, gcov_type bottom, int dp) { static char buffer[20]; + /* Handle invalid values that would result in a misleading value. */ + if (bottom != 0 && top > bottom && dp >= 0) + { + sprintf (buffer, "NAN %%"); + return buffer; + } + if (dp >= 0) { float ratio = bottom ? (float)top / bottom : 0;