From 7ae9afc40f7b603ace4ad1690d0092b018932ed0 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Fri, 1 Jul 2011 14:16:41 +1000 Subject: [PATCH] Profile points and warning clean ups. --- cpu-miner.c | 19 +++++++++++-------- findnonce.c | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index dfb6b2e4..a74575f0 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -400,8 +400,10 @@ static bool get_upstream_work(CURL *curl, struct work *work) val = json_rpc_call(curl, rpc_url, rpc_userpass, rpc_req, want_longpoll, false); - if (!val) + if (unlikely(!val)) { + applog(LOG_ERR, "Failed json_rpc_call in get_upstream_work"); return false; + } rc = work_decode(json_object_get(val, "result"), work); @@ -465,7 +467,7 @@ static void *get_work_thread(void *userdata) int failures = 0; ret_work = calloc(1, sizeof(*ret_work)); - if (!ret_work) { + if (unlikely(!ret_work)) { applog(LOG_ERR, "Failed to calloc ret_work in workio_get_work"); kill_work(); goto out; @@ -510,7 +512,8 @@ static bool workio_get_work(struct workio_cmd *wc, CURL *curl) id->wc = wc; id->curl = curl; - if (!get_thread) { + if (unlikely(!get_thread)) { + /* This is only instantiated once at startup */ get_thread = malloc(sizeof(get_thread)); if (unlikely(!get_thread)) { applog(LOG_ERR, "Failed to malloc get_thread in workio_get_work"); @@ -519,7 +522,7 @@ static bool workio_get_work(struct workio_cmd *wc, CURL *curl) } else pthread_join(*get_thread, NULL); - if (pthread_create(get_thread, NULL, get_work_thread, (void *)id)) { + if (unlikely(pthread_create(get_thread, NULL, get_work_thread, (void *)id))) { applog(LOG_ERR, "Failed to create get_work_thread"); free(id); return false; @@ -565,7 +568,7 @@ static bool workio_submit_work(struct workio_cmd *wc, CURL *curl) id->wc = wc; id->curl = curl; - if (!submit_thread) { + if (unlikely(!submit_thread)) { submit_thread = malloc(sizeof(submit_thread)); if (unlikely(!submit_thread)) { applog(LOG_ERR, "Failed to malloc submit_thread in workio_submit_work"); @@ -574,7 +577,7 @@ static bool workio_submit_work(struct workio_cmd *wc, CURL *curl) } else pthread_join(*submit_thread, NULL); - if (pthread_create(submit_thread, NULL, submit_work_thread, (void *)id)) { + if (unlikely(pthread_create(submit_thread, NULL, submit_work_thread, (void *)id))) { applog(LOG_ERR, "Failed to create submit_work_thread"); free(id); return false; @@ -905,7 +908,7 @@ static void *miner_thread(void *userdata) if (unlikely(rc)) { if (opt_debug) applog(LOG_DEBUG, "CPU %d found something?", cpu_from_thr_id(thr_id)); - if (!submit_work_sync(mythr, &work)) + if (unlikely(!submit_work_sync(mythr, &work))) break; } } @@ -1379,7 +1382,7 @@ int main (int argc, char *argv[]) struct thr_info *thr; unsigned int i; char name[32]; - struct cgpu_info *gpus, *cpus; + struct cgpu_info *gpus = NULL, *cpus = NULL; #ifdef WIN32 opt_n_threads = num_processors = 1; diff --git a/findnonce.c b/findnonce.c index 2502091d..1f8ef796 100644 --- a/findnonce.c +++ b/findnonce.c @@ -148,7 +148,7 @@ static void *postcalc_hash(void *userdata) struct thr_info *thr = pcd->thr; dev_blk_ctx *blk = &pcd->work->blk; struct work *work = pcd->work; - uint32_t start; + uint32_t start = 0; cl_uint A, B, C, D, E, F, G, H; cl_uint W[16];