diff --git a/elist.h b/elist.h index afd59371..b47e9426 100644 --- a/elist.h +++ b/elist.h @@ -30,14 +30,14 @@ struct list_head { * This is only for internal list manipulation where we know * the prev/next entries already! */ -static inline void __list_add(struct list_head *new, +static inline void __list_add(struct list_head *newhead, struct list_head *prev, struct list_head *next) { - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; + next->prev = newhead; + newhead->next = next; + newhead->prev = prev; + prev->next = newhead; } /** @@ -48,9 +48,9 @@ static inline void __list_add(struct list_head *new, * Insert a new entry after the specified head. * This is good for implementing stacks. */ -static inline void list_add(struct list_head *new, struct list_head *head) +static inline void list_add(struct list_head *newhead, struct list_head *head) { - __list_add(new, head, head->next); + __list_add(newhead, head, head->next); } /** @@ -61,9 +61,9 @@ static inline void list_add(struct list_head *new, struct list_head *head) * Insert a new entry before the specified head. * This is useful for implementing queues. */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) +static inline void list_add_tail(struct list_head *newhead, struct list_head *head) { - __list_add(new, head->prev, head); + __list_add(newhead, head->prev, head); } /* @@ -87,8 +87,8 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); - entry->next = (void *) 0; - entry->prev = (void *) 0; + entry->next = NULL; + entry->prev = NULL; } /** @@ -180,12 +180,12 @@ static inline void list_splice_init(struct list_head *list, * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ -#ifndef _WIN64 +#ifndef _MSC_VER #define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + ((type)((char *)(ptr)-(unsigned long)(&((type)0)->member))) #else -#define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long long)(&((type *)0)->member))) +#define list_entry(ptr, ptrtype, member) \ + (reinterpret_cast((char *)(ptr)-(char *)(&(reinterpret_cast(1)->member)) + 1)) #endif /** @@ -221,10 +221,17 @@ static inline void list_splice_init(struct list_head *list, * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) +#ifndef _MSC_VER +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) +#else +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(pos), member)) +#endif /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry @@ -233,11 +240,21 @@ static inline void list_splice_init(struct list_head *list, * @head: the head for your list. * @member: the name of the list_struct within the struct. */ +#ifndef _MSC_VER +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(pos), member), \ + n = list_entry(pos->member.next, typeof(pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(n), member)) + +#else + #define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) + for (pos = list_entry((head)->next, decltype(pos), member), \ + n = list_entry(pos->member.next, decltype(pos), member); \ + &(pos->member) != (head); \ + pos = n, n = list_entry(n->member.next, decltype(n), member)) +#endif /** * list_for_each_entry_continue - iterate over list of given type diff --git a/sgminer.c b/sgminer.c index 4f73f886..be9bbade 100644 --- a/sgminer.c +++ b/sgminer.c @@ -273,7 +273,9 @@ static int include_count; static int forkpid; #endif // defined(unix) +#ifndef _MSC_VER struct sigaction termhandler, inthandler; +#endif struct thread_q *getq; @@ -505,7 +507,7 @@ struct pool *add_pool(void) { struct pool *pool; - pool = calloc(sizeof(struct pool), 1); + pool = (struct pool *)calloc(sizeof(struct pool), 1); if (!pool) quit(1, "Failed to malloc pool in add_pool"); pool->pool_no = pool->prio = total_pools; @@ -518,7 +520,6 @@ struct pool *add_pool(void) pool->has_stratum ? pool->stratum_port : ""); pool->poolname = strdup(buf); - pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2)); pools[total_pools++] = pool; mutex_init(&pool->pool_lock); if (unlikely(pthread_cond_init(&pool->cr_cond, NULL))) @@ -718,7 +719,7 @@ static void setup_url(struct pool *pool, char *arg) strncmp(arg, "https://", 8)) { char *httpinput; - httpinput = malloc(255); + httpinput = (char *)malloc(255); if (!httpinput) quit(1, "Failed to malloc httpinput"); strcpy(httpinput, "http://"); @@ -1449,7 +1450,7 @@ static char *load_config(const char *arg, void __maybe_unused *unused) #endif if (!json_is_object(config)) { siz = JSON_LOAD_ERROR_LEN + strlen(arg) + strlen(err.text); - json_error = malloc(siz); + json_error = (char *)malloc(siz); if (!json_error) quit(1, "Malloc failure in json error"); @@ -1475,7 +1476,7 @@ void default_save_file(char *filename); static void load_default_config(void) { - cnfbuf = malloc(PATH_MAX); + cnfbuf = (char *)malloc(PATH_MAX); default_save_file(cnfbuf); @@ -1545,7 +1546,7 @@ static bool jobj_binary(const json_t *obj, const char *key, applog(LOG_ERR, "JSON key '%s' is not a string", key); return false; } - if (!hex2bin(buf, hexstr, buflen)) + if (!hex2bin((unsigned char *)buf, hexstr, buflen)) return false; return true; @@ -1567,35 +1568,35 @@ static void calc_midstate(struct work *work) static struct work *make_work(void) { - struct work *work = calloc(1, sizeof(struct work)); + struct work *w = (struct work *)calloc(1, sizeof(struct work)); - if (unlikely(!work)) + if (unlikely(!w)) quit(1, "Failed to calloc work in make_work"); cg_wlock(&control_lock); - work->id = total_work++; + w->id = total_work++; cg_wunlock(&control_lock); - return work; + return w; } /* This is the central place all work that is about to be retired should be * cleaned to remove any dynamically allocated arrays within the struct */ -void clean_work(struct work *work) +void clean_work(struct work *w) { - free(work->job_id); - free(work->ntime); - free(work->coinbase); - free(work->nonce1); - memset(work, 0, sizeof(struct work)); + free(w->job_id); + free(w->ntime); + free(w->coinbase); + free(w->nonce1); + memset(w, 0, sizeof(struct work)); } /* All dynamically allocated work structs should be freed here to not leak any * ram from arrays allocated within the work struct */ -void free_work(struct work *work) +void free_work(struct work *w) { - clean_work(work); - free(work); + clean_work(w); + free(w); } static void gen_hash(unsigned char *data, unsigned char *hash, int len); @@ -1627,7 +1628,7 @@ static bool __build_gbt_txns(struct pool *pool, json_t *res_val) if (!pool->gbt_txns) goto out; - pool->txn_hashes = calloc(32 * (pool->gbt_txns + 1), 1); + pool->txn_hashes = (unsigned char *)calloc(32 * (pool->gbt_txns + 1), 1); if (unlikely(!pool->txn_hashes)) quit(1, "Failed to calloc txn_hashes in __build_gbt_txns"); @@ -1639,7 +1640,7 @@ static bool __build_gbt_txns(struct pool *pool, json_t *res_val) cal_len = txn_len; align_len(&cal_len); - txn_bin = calloc(cal_len, 1); + txn_bin = (unsigned char *)calloc(cal_len, 1); if (unlikely(!txn_bin)) quit(1, "Failed to calloc txn_bin in __build_gbt_txns"); if (unlikely(!hex2bin(txn_bin, txn, txn_len / 2))) @@ -1657,7 +1658,7 @@ static unsigned char *__gbt_merkleroot(struct pool *pool) unsigned char *merkle_hash; int i, txns; - merkle_hash = calloc(32 * (pool->gbt_txns + 2), 1); + merkle_hash = (unsigned char *)calloc(32 * (pool->gbt_txns + 2), 1); if (unlikely(!merkle_hash)) quit(1, "Failed to calloc merkle_hash in __gbt_merkleroot"); @@ -1837,7 +1838,7 @@ static bool gbt_decode(struct pool *pool, json_t *res_val) cal_len = pool->coinbase_len + 1; align_len(&cal_len); free(pool->coinbase); - pool->coinbase = calloc(cal_len, 1); + pool->coinbase = (unsigned char *)calloc(cal_len, 1); if (unlikely(!pool->coinbase)) quit(1, "Failed to calloc pool coinbase in gbt_decode"); hex2bin(pool->coinbase, pool->coinbasetxn, 42); @@ -1984,7 +1985,7 @@ static int devcursor, logstart, logcursor; /* statusy is where the status window goes up to in cases where it won't fit at startup */ static int statusy; #endif -struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */ +extern struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */ #ifdef HAVE_CURSES static inline void unlock_curses(void) @@ -2155,7 +2156,7 @@ static void curses_print_status(void) static void adj_width(int var, int *length) { - if ((int)(log10(var) + 1) > *length) + if ((int)(log10((double)var) + 1) > *length) (*length)++; } @@ -2579,34 +2580,34 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) } else if (work->gbt_txns <= 0xffff) { uint16_t val = htole16(work->gbt_txns); - gbt_block = realloc_strcat(gbt_block, "fd"); + gbt_block = (char *)realloc_strcat(gbt_block, "fd"); varint = bin2hex((const unsigned char *)&val, 2); } else { uint32_t val = htole32(work->gbt_txns); - gbt_block = realloc_strcat(gbt_block, "fe"); + gbt_block = (char *)realloc_strcat(gbt_block, "fe"); varint = bin2hex((const unsigned char *)&val, 4); } - gbt_block = realloc_strcat(gbt_block, varint); + gbt_block = (char *)realloc_strcat(gbt_block, varint); free(varint); - gbt_block = realloc_strcat(gbt_block, work->coinbase); + gbt_block = (char *)realloc_strcat(gbt_block, work->coinbase); s = strdup("{\"id\": 0, \"method\": \"submitblock\", \"params\": [\""); - s = realloc_strcat(s, gbt_block); + s = (char *)realloc_strcat(s, gbt_block); if (work->job_id) { - s = realloc_strcat(s, "\", {\"workid\": \""); - s = realloc_strcat(s, work->job_id); - s = realloc_strcat(s, "\"}]}"); + s = (char *)realloc_strcat(s, "\", {\"workid\": \""); + s = (char *)realloc_strcat(s, work->job_id); + s = (char *)realloc_strcat(s, "\"}]}"); } else - s = realloc_strcat(s, "\", {}]}"); + s = (char *)realloc_strcat(s, "\", {}]}"); free(gbt_block); } else { s = strdup("{\"method\": \"getwork\", \"params\": [ \""); - s = realloc_strcat(s, hexstr); - s = realloc_strcat(s, "\" ], \"id\":1}"); + s = (char *)realloc_strcat(s, hexstr); + s = (char *)realloc_strcat(s, "\" ], \"id\":1}"); } applog(LOG_DEBUG, "DBG: sending %s submit RPC call: %s", pool->rpc_url, s); - s = realloc_strcat(s, "\n"); + s = (char *)realloc_strcat(s, "\n"); cgtime(&tv_submit); /* issue JSON-RPC request */ @@ -2899,13 +2900,13 @@ 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); @@ -3133,9 +3134,11 @@ void app_restart(void) static void sighandler(int __maybe_unused sig) { +#ifndef _MSC_VER /* Restore signal handlers so we can still quit if kill_work fails */ sigaction(SIGTERM, &termhandler, NULL); sigaction(SIGINT, &inthandler, NULL); +#endif kill_work(); } @@ -3144,7 +3147,7 @@ static void sighandler(int __maybe_unused sig) * this pool. */ static void recruit_curl(struct pool *pool) { - struct curl_ent *ce = calloc(sizeof(struct curl_ent), 1); + struct curl_ent *ce = (struct curl_ent *)calloc(sizeof(struct curl_ent), 1); if (unlikely(!ce)) quit(1, "Failed to calloc in recruit_curl"); @@ -3182,7 +3185,8 @@ retry: recruited = true; } } - ce = list_entry(pool->curlring.next, struct curl_ent, node); + ce = list_entry(pool->curlring.next, struct curl_ent*, node); + list_del(&ce->node); mutex_unlock(&pool->pool_lock); @@ -3899,7 +3903,7 @@ static bool test_work_current(struct work *work) /* Search to see if this block exists yet and if not, consider it a * new block and set the current block details to this one */ if (!block_exists(hexstr)) { - struct block *s = calloc(sizeof(struct block), 1); + struct block *s = (struct block *)calloc(sizeof(struct block), 1); int deleted_block = 0; if (unlikely(!s)) @@ -4104,9 +4108,9 @@ static char *json_escape(char *str) char *buf, *ptr; /* 2x is the max, may as well just allocate that */ - ptr = buf = malloc(strlen(str) * 2 + 1); + ptr = buf = (char *)malloc(strlen(str) * 2 + 1); - jeptr = malloc(sizeof(*jeptr)); + jeptr = (struct JE *)malloc(sizeof(*jeptr)); jeptr->buf = buf; jeptr->next = jedata; @@ -4579,7 +4583,7 @@ retry: goto retry; } } - pool_strategy = selected; + pool_strategy = (enum pool_strategy)selected; switch_pools(NULL); goto updated; } else if (!strncasecmp(&input, "i", 1)) { @@ -4854,7 +4858,7 @@ static void *input_thread(void __maybe_unused *userdata) static void *api_thread(void *userdata) { - struct thr_info *mythr = userdata; + struct thr_info *mythr = (struct thr_info *)userdata; pthread_detach(pthread_self()); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); @@ -5362,7 +5366,7 @@ static void *stratum_sthread(void *userdata) if (unlikely(pool->removed)) break; - work = tq_pop(pool->stratum_q, NULL); + work = (struct work *)tq_pop(pool->stratum_q, NULL); if (unlikely(!work)) quit(1, "Stratum q returned empty work"); @@ -5373,7 +5377,7 @@ static void *stratum_sthread(void *userdata) continue; } - sshare = calloc(sizeof(struct stratum_share), 1); + sshare = (struct stratum_share *)calloc(sizeof(struct stratum_share), 1); hash32 = (uint32_t *)work->hash; submitted = false; @@ -5541,11 +5545,11 @@ retry_stratum: json_t *arrval = json_array_get(mutables, i); if (json_is_string(arrval)) { - const char *mutable = json_string_value(arrval); + const char *mut = json_string_value(arrval); - if (!strncasecmp(mutable, "coinbase/append", 15)) + if (!strncasecmp(mut, "coinbase/append", 15)) append = true; - else if (!strncasecmp(mutable, "submit/coinbase", 15)) + else if (!strncasecmp(mut, "submit/coinbase", 15)) submit = true; } } @@ -5631,7 +5635,7 @@ retry_stratum: need_slash = true; siz = strlen(pool->rpc_url) + strlen(copy_start) + 2; - pool->lp_url = malloc(siz); + pool->lp_url = (char *)malloc(siz); if (!pool->lp_url) { applog(LOG_ERR, "Malloc failure in pool_active"); return false; @@ -6092,7 +6096,7 @@ static void hash_sole_work(struct thr_info *mythr) struct sgminer_stats *dev_stats = &(cgpu->sgminer_stats); struct sgminer_stats *pool_stats; /* Try to cycle approximately 5 times before each log update */ - const long cycle = opt_log_interval / 5 ? : 1; + const long cycle = opt_log_interval / 5 ? 5 : 1; const bool primary = (!mythr->device_thread) || mythr->primary_thread; struct timeval diff, sdiff, wdiff = {0, 0}; uint32_t max_nonce = drv->can_limit_work(mythr); @@ -6529,7 +6533,7 @@ void hash_driver_work(struct thr_info *mythr) void *miner_thread(void *userdata) { - struct thr_info *mythr = userdata; + struct thr_info *mythr = (struct thr_info *)userdata; const int thr_id = mythr->id; struct cgpu_info *cgpu = mythr->cgpu; struct device_drv *drv = cgpu->drv; @@ -7200,7 +7204,7 @@ char *curses_input(const char *query) char *input; echo(); - input = malloc(255); + input = (char *)malloc(255); if (!input) quit(1, "Failed to malloc input"); leaveok(logwin, false); @@ -7258,7 +7262,7 @@ bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char pool->rpc_user = user; pool->rpc_pass = pass; siz = strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2; - pool->rpc_userpass = malloc(siz); + pool->rpc_userpass = (char *)malloc(siz); if (!pool->rpc_userpass) quit(1, "Failed to malloc userpass"); snprintf(pool->rpc_userpass, siz, "%s:%s", pool->rpc_user, pool->rpc_pass); @@ -7304,7 +7308,7 @@ static bool input_pool(bool live) strncmp(url, "https://", 8)) { char *httpinput; - httpinput = malloc(256); + httpinput = (char *)malloc(256); if (!httpinput) quit(1, "Failed to malloc httpinput"); strcpy(httpinput, "http://"); @@ -7577,14 +7581,14 @@ bool add_cgpu(struct cgpu_info *cgpu) if (d) cgpu->device_id = ++d->lastid; else { - d = malloc(sizeof(*d)); + d = (struct _cgpu_devid_counter *)malloc(sizeof(*d)); memcpy(d->name, cgpu->drv->name, sizeof(d->name)); cgpu->device_id = d->lastid = 0; HASH_ADD_STR(devids, name, d); } wr_lock(&devices_lock); - devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + new_devices + 2)); + devices = (struct cgpu_info **)realloc(devices, sizeof(struct cgpu_info *) * (total_devices + new_devices + 2)); wr_unlock(&devices_lock); mutex_lock(&stats_lock); @@ -7604,7 +7608,7 @@ struct device_drv *copy_drv(struct device_drv *drv) { struct device_drv *copy; - if (unlikely(!(copy = malloc(sizeof(*copy))))) { + if (unlikely(!(copy = (struct device_drv *)malloc(sizeof(*copy))))) { quit(1, "Failed to allocate device_drv copy of %s (%s)", drv->name, drv->copy ? "copy" : "original"); } @@ -7630,7 +7634,9 @@ static void probe_pools(void) int main(int argc, char *argv[]) { +#ifndef _MSC_VER struct sigaction handler; +#endif struct thr_info *thr; struct block *block; unsigned int k; @@ -7648,7 +7654,7 @@ int main(int argc, char *argv[]) quithere(1, "Failed to pthread_mutex_init lockstat_lock errno=%d", errno); #endif - initial_args = malloc(sizeof(char *) * (argc + 1)); + initial_args = (const char **)malloc(sizeof(char *)* (argc + 1)); for (i = 0; i < argc; i++) initial_args[i] = strdup(argv[i]); initial_args[argc] = NULL; @@ -7685,29 +7691,38 @@ int main(int argc, char *argv[]) snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, VERSION); - handler.sa_handler = &sighandler; - handler.sa_flags = 0; - sigemptyset(&handler.sa_mask); - sigaction(SIGTERM, &handler, &termhandler); - sigaction(SIGINT, &handler, &inthandler); #ifndef WIN32 signal(SIGPIPE, SIG_IGN); #else timeBeginPeriod(1); #endif - opt_kernel_path = alloca(PATH_MAX); + +#ifndef _MSC_VER + handler.sa_handler = &sighandler; + handler.sa_flags = 0; + sigemptyset(&handler.sa_mask); + sigaction(SIGTERM, &handler, &termhandler); + sigaction(SIGINT, &handler, &inthandler); + + opt_kernel_path = (char *)alloca(PATH_MAX); strcpy(opt_kernel_path, SGMINER_PREFIX); - sgminer_path = alloca(PATH_MAX); + sgminer_path = (char *)alloca(PATH_MAX); s = strdup(argv[0]); strcpy(sgminer_path, dirname(s)); free(s); strcat(sgminer_path, "/"); +#else + opt_kernel_path = (char*)alloca(PATH_MAX); + strcpy(opt_kernel_path, SGMINER_PREFIX); + sgminer_path = (char*)alloca(PATH_MAX); + GetCurrentDirectory(PATH_MAX - 1, sgminer_path); +#endif devcursor = 8; logstart = devcursor + 1; logcursor = logstart + 1; - block = calloc(sizeof(struct block), 1); + block = (struct block *)calloc(sizeof(struct block), 1); if (unlikely(!block)) quit (1, "main OOM"); for (i = 0; i < 36; i++) @@ -7740,7 +7755,7 @@ int main(int argc, char *argv[]) // FIXME: executes always (leftover from SHA256d days) quit(1, "Cannot use benchmark mode with scrypt"); pool = add_pool(); - pool->rpc_url = malloc(255); + pool->rpc_url = (char *)malloc(255); strcpy(pool->rpc_url, "Benchmark"); pool->rpc_user = pool->rpc_url; pool->rpc_pass = pool->rpc_url; @@ -7783,7 +7798,7 @@ int main(int argc, char *argv[]) opt_log_output = true; total_control_threads = 8; - control_thr = calloc(total_control_threads, sizeof(*thr)); + control_thr = (struct thr_info *)calloc(total_control_threads, sizeof(*thr)); if (!control_thr) quit(1, "Failed to calloc control_thr"); @@ -7869,7 +7884,7 @@ int main(int argc, char *argv[]) if (!pool->rpc_user || !pool->rpc_pass) quit(1, "No login credentials supplied for %s", pool->poolname); siz = strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2; - pool->rpc_userpass = malloc(siz); + pool->rpc_userpass = (char *)malloc(siz); if (!pool->rpc_userpass) quit(1, "Failed to malloc userpass"); snprintf(pool->rpc_userpass, siz, "%s:%s", pool->rpc_user, pool->rpc_pass); @@ -7888,11 +7903,11 @@ int main(int argc, char *argv[]) fork_monitor(); #endif // defined(unix) - mining_thr = calloc(mining_threads, sizeof(thr)); + mining_thr = (struct thr_info **)calloc(mining_threads, sizeof(thr)); if (!mining_thr) quit(1, "Failed to calloc mining_thr"); for (i = 0; i < mining_threads; i++) { - mining_thr[i] = calloc(1, sizeof(*thr)); + mining_thr[i] = (struct thr_info *)calloc(1, sizeof(*thr)); if (!mining_thr[i]) quit(1, "Failed to calloc mining_thr[%d]", i); } @@ -7901,7 +7916,7 @@ int main(int argc, char *argv[]) k = 0; for (i = 0; i < total_devices; ++i) { struct cgpu_info *cgpu = devices[i]; - cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1)); + cgpu->thr = (struct thr_info **)malloc(sizeof(*cgpu->thr) * (cgpu->threads+1)); cgpu->thr[cgpu->threads] = NULL; cgpu->status = LIFE_INIT; diff --git a/util.c b/util.c index 2fa4938d..4ed978ba 100644 --- a/util.c +++ b/util.c @@ -804,7 +804,7 @@ void *tq_pop(struct thread_q *tq, const struct timespec *abstime) if (list_empty(&tq->q)) goto out; pop: - ent = list_entry(tq->q.next, struct tq_ent, q_node); + ent = list_entry(tq->q.next, struct tq_ent*, q_node); rval = ent->data; list_del(&ent->q_node);