Commit 6f8dde993d36a98d94accb9b26ab5f99705fabf2

Con Kolivas 2014-03-23T22:35:01

Fix 32bit overflow on relative diff shown.

diff --git a/cgminer.c b/cgminer.c
index 13b1bef..ea74951 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3040,7 +3040,8 @@ static void show_hash(struct work *work, char *hashshow)
 	char diffdisp[16];
 	unsigned long h32;
 	uint32_t *hash32;
-	int intdiff, ofs;
+	uint64_t uintdiff;
+	int ofs;
 
 	swab256(rhash, work->hash);
 	for (ofs = 0; ofs <= 28; ofs ++) {
@@ -3049,9 +3050,9 @@ static void show_hash(struct work *work, char *hashshow)
 	}
 	hash32 = (uint32_t *)(rhash + ofs);
 	h32 = be32toh(*hash32);
-	intdiff = round(work->work_difficulty);
+	uintdiff = round(work->work_difficulty);
 	suffix_string(work->share_diff, diffdisp, sizeof (diffdisp), 0);
-	snprintf(hashshow, 64, "%08lx Diff %s/%d%s", h32, diffdisp, intdiff,
+	snprintf(hashshow, 64, "%08lx Diff %s/%"PRIu64"%s", h32, diffdisp, uintdiff,
 		 work->block? " BLOCK!" : "");
 }