File 0003-stats-report-zero-percents-instead-of-NaN.patch of Package latrace

From 2849dc00038e6b18403ffae653c89ae0b835a14a Mon Sep 17 00:00:00 2001
From: Akos PASZTORY <akos.pasztory@gmail.com>
Date: Sat, 3 Dec 2011 15:42:57 +0000
Subject: [PATCH 3/4] stats: report zero percents instead of NaN

---
 ChangeLog   | 1 +
 src/stats.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9afa02c..f752b62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2011-12-05 Jiri Olsa <olsajiri@gmail.com>
 	* stats bugfix - use timersub() and timeradd()
+	* stats - report zero percents instead of NaN
 	  (contributed by Akos Pasztory <akos.pasztory@gmail.com>)
 
 2011-09-05 Jiri Olsa <olsajiri@gmail.com>
diff --git a/src/stats.c b/src/stats.c
index d5c5351..410c68e 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <setjmp.h>
+#include <math.h>
 
 #include "config.h"
 
@@ -229,6 +230,8 @@ static int lt_stats_show_thread(struct lt_config_app *cfg, struct lt_thread *t)
 		u_int time_sym = sym->tv_all.tv_sec*1000000 + sym->tv_all.tv_usec;
 
 		sym->percent = time_sym / (time_global/100);
+		if (isnan(sym->percent))
+			sym->percent = 0.0f;
 		sym->usec_call = time_sym/sym->call;
 	}
 
-- 
2.35.3

openSUSE Build Service is sponsored by