[PATCH 7/7] shared/tester: Fix divide by zero error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Before adding a check - o/p:
Total: 0, Passed: 0 (-nan%), Failed: 0, Not Run: 0

After check - o/p:
Total: 0, Passed: 0 (0.0%), Failed: 0, Not Run: 0
---
 src/shared/tester.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/shared/tester.c b/src/shared/tester.c
index d05bf08..3c3089f 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -319,7 +319,8 @@ static int tester_summarize(void)
 		COLOR_RED "Failed: %d" COLOR_OFF ", "
 		COLOR_YELLOW "Not Run: %d" COLOR_OFF "\n",
 			not_run + passed + failed, passed,
-			(float) passed * 100 / (not_run + passed + failed),
+			(not_run + passed + failed) ?
+			(float) passed * 100 / (not_run + passed + failed) : 0,
 			failed, not_run);
 
 	execution_time = g_timer_elapsed(test_timer, NULL);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux