From d9eb547c5a9b65986422ec78b3bb72e541599f2c Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Tue, 28 Jan 2014 20:30:00 +0200 Subject: [PATCH] VS2010 build: revert le256todouble() cast/ref/deref change. Introduced by commit 87e5f35745321132cea3e5b21ddb7d69e8a8eb0f The cast/ref/deref is performed wrong and breaks share/best share display. It is not the value of target that should be increased, but its address. If all else fails, add an `#ifdef _MSVC_VER`; we should avoid it if possible. In either case, constructs like `&(*(((uint64_t *)target) + 24))` must be explained (in a comment). --- sgminer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sgminer.c b/sgminer.c index 0ec30255..9b955454 100644 --- a/sgminer.c +++ b/sgminer.c @@ -2521,7 +2521,7 @@ static void show_hash(struct work *work, char *hashshow) intdiff = round(work->work_difficulty); suffix_string(work->share_diff, diffdisp, sizeof (diffdisp), 0); snprintf(hashshow, 64, "%08lx Diff %s/%d%s", h32, diffdisp, intdiff, - work->block? " BLOCK!" : ""); + work->block ? " BLOCK!" : ""); } #ifdef HAVE_LIBCURL @@ -2901,16 +2901,16 @@ static double le256todouble(const void *target) uint64_t *data64; double dcut64; - data64 = &(*(((uint64_t *)target) + 24)); + data64 = (uint64_t *)(target + 24); dcut64 = le64toh(*data64) * bits192; - data64 = &(*(((uint64_t *)target) + 16)); + data64 = (uint64_t *)(target + 16); dcut64 += le64toh(*data64) * bits128; - data64 = &(*(((uint64_t *)target) + 8)); + data64 = (uint64_t *)(target + 8); dcut64 += le64toh(*data64) * bits64; - data64 = (uint64_t *)(target); + data64 = (uint64_t *)target; dcut64 += le64toh(*data64); return dcut64; @@ -3557,6 +3557,7 @@ static uint64_t share_diff(const struct work *work) s64 = 0; ret = round(d64 / s64); + applog(LOG_DEBUG, "Found share with difficulty %lu", ret); cg_wlock(&control_lock); if (unlikely(ret > best_diff)) {