printf-utils: Fix division by zero if total is zero

This commit is contained in:
Pali Rohár committed 2014-11-18 18:04:45 +01:00
1 parent 99608d2b3f
commit 79a171e823
1 file changed
+1 -1
+1 -1
View File
@@ -39,7 +39,7 @@ void printf_progressbar(unsigned long long part, unsigned long long total) {
int tmp, cols = 80;
/* percentage calculation */
pc = (int)(part*100/total);
pc = total==0?100:(int)(part*100/total);
(pc<0)?pc=0:(pc>100)?pc=100:0;
PRINTF_BACK();