aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-04-28 14:51:22 +0200
committerMartin Liska <marxin@gcc.gnu.org>2017-04-28 12:51:22 +0000
commit07ea19a797c6087725fe5b9f2630871c52020311 (patch)
tree0f970f383df443d918f9f004c550ec813fc6d5c1 /gcc/gcov.c
parent6e49961ce47b8c554ff6081ef95a68a0616f0a93 (diff)
downloadgcc-07ea19a797c6087725fe5b9f2630871c52020311.zip
gcc-07ea19a797c6087725fe5b9f2630871c52020311.tar.gz
gcc-07ea19a797c6087725fe5b9f2630871c52020311.tar.bz2
Fix format_gcov to not print misleading values (PR gcov-profile/53915)
2017-04-28 Martin Liska <mliska@suse.cz> PR gcov-profile/53915 * gcov.c (format_gcov): Print 'NAN %' when top > bottom. From-SVN: r247375
Diffstat (limited to 'gcc/gcov.c')
-rw-r--r--gcc/gcov.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/gcov.c b/gcc/gcov.c
index b25464e..924a5a3 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;