Merge branch 'master' of git://github.com/ckolivas/cgminer.git Conflicts: driver-bitforce.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/cgminer.c b/cgminer.c
index f37fa03..6086d57 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -339,25 +339,35 @@ static FILE *sharelog_file = NULL;
static void sharelog(const char*disposition, const struct work*work)
{
+ char *target, *hash, *data;
+ struct cgpu_info *cgpu;
+ unsigned long int t;
+ struct pool *pool;
+ int thr_id, rv;
+ char s[1024];
+ size_t ret;
+
if (!sharelog_file)
return;
- int thr_id = work->thr_id;
- struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
- struct pool *pool = work->pool;
- unsigned long int t = (unsigned long int)work->share_found_time;
- char *target = bin2hex(work->target, sizeof(work->target));
+ thr_id = work->thr_id;
+ cgpu = thr_info[thr_id].cgpu;
+ pool = work->pool;
+ t = (unsigned long int)work->share_found_time;
+ target = bin2hex(work->target, sizeof(work->target));
if (unlikely(!target)) {
applog(LOG_ERR, "sharelog target OOM");
return;
}
- char *hash = bin2hex(work->hash, sizeof(work->hash));
+
+ hash = bin2hex(work->hash, sizeof(work->hash));
if (unlikely(!hash)) {
free(target);
applog(LOG_ERR, "sharelog hash OOM");
return;
}
- char *data = bin2hex(work->data, sizeof(work->data));
+
+ data = bin2hex(work->data, sizeof(work->data));
if (unlikely(!data)) {
free(target);
free(hash);
@@ -366,26 +376,22 @@ static void sharelog(const char*disposition, const struct work*work)
}
// timestamp,disposition,target,pool,dev,thr,sharehash,sharedata
- char s[1024];
- int rv;
rv = snprintf(s, sizeof(s), "%lu,%s,%s,%s,%s%u,%u,%s,%s\n", t, disposition, target, pool->rpc_url, cgpu->api->name, cgpu->device_id, thr_id, hash, data);
free(target);
free(hash);
free(data);
if (rv >= (int)(sizeof(s)))
s[sizeof(s) - 1] = '\0';
- else
- if (rv < 0) {
+ else if (rv < 0) {
applog(LOG_ERR, "sharelog printf error");
return;
}
- size_t ret;
mutex_lock(&sharelog_lock);
ret = fwrite(s, rv, 1, sharelog_file);
fflush(sharelog_file);
mutex_unlock(&sharelog_lock);
- if (1 != ret)
+ if (ret != 1)
applog(LOG_ERR, "sharelog fwrite error");
}
@@ -1013,8 +1019,8 @@ static int fileconf_load;
static char *parse_config(json_t *config, bool fileconf)
{
static char err_buf[200];
- json_t *val;
struct opt_table *opt;
+ json_t *val;
if (fileconf && !fileconf_load)
fileconf_load = 1;
diff --git a/driver-bitforce.c b/driver-bitforce.c
index eb49be4..5328077 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -365,8 +365,6 @@ static void biforce_thread_enable(struct thr_info *thr)
bitforce_init(bitforce);
}
-
-
static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint64_t __maybe_unused max_nonce)
{
struct cgpu_info *bitforce = thr->cgpu;