Commit 5154e8472db081d15a1efa09d3853f654c5394a9

Kano 2013-09-24T12:46:09

klondike - avoid division by zero if maxcount is unexpectedly zero

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/driver-klondike.c b/driver-klondike.c
index 389444a..b3ffe37 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -537,7 +537,8 @@ static int64_t klondike_scanwork(struct thr_info *thr)
 				newhashdev += klninfo->status[dev].maxcount; // hash counter wrapped
 			newhashdev += klninfo->status[dev].hashcount - klninfo->devinfo[dev].lasthashcount;
 			klninfo->devinfo[dev].lasthashcount = klninfo->status[dev].hashcount;
-			klninfo->hashcount += (newhashdev << 32) / klninfo->status[dev].maxcount;
+			if (klninfo->status[dev].maxcount != 0)
+				klninfo->hashcount += (newhashdev << 32) / klninfo->status[dev].maxcount;
 
 			// todo: check stats for critical conditions
 		}