From 6c5ce535d9f2b7a8c0385c0934f4394510c8af39 Mon Sep 17 00:00:00 2001 From: Jan Berdajs Date: Thu, 29 May 2014 01:08:57 +0200 Subject: [PATCH] fix compiler warnings --- animecoin.c | 4 ---- darkcoin.c | 4 ---- driver-opencl.c | 22 ++++++++++++++-------- driver-opencl.h | 14 +++++++------- fuguecoin.c | 4 ---- groestlcoin.c | 5 ----- inkcoin.c | 4 ---- marucoin.c | 4 ---- myriadcoin-groestl.c | 4 ---- quarkcoin.c | 4 ---- qubitcoin.c | 4 ---- sgminer.c | 14 ++++++-------- sifcoin.c | 4 ---- twecoin.c | 4 ---- util.c | 2 +- util.h | 1 + 16 files changed, 29 insertions(+), 69 deletions(-) diff --git a/animecoin.c b/animecoin.c index 655a3e32..75f862af 100644 --- a/animecoin.c +++ b/animecoin.c @@ -149,11 +149,9 @@ int animecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); animehash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -171,7 +169,6 @@ int animecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t void animecoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -186,7 +183,6 @@ bool scanhash_animecoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/darkcoin.c b/darkcoin.c index 45529b3c..192ab2ab 100644 --- a/darkcoin.c +++ b/darkcoin.c @@ -149,11 +149,9 @@ int darkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t n { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); xhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -171,7 +169,6 @@ int darkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t n void darkcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -186,7 +183,6 @@ bool scanhash_darkcoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/driver-opencl.c b/driver-opencl.c index 915e7c41..d82b5f81 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -169,10 +169,11 @@ char *set_lookup_gap(char *arg) return NULL; } -char *set_thread_concurrency(char *arg) +char *set_thread_concurrency(const char *_arg) { int i, val = 0, device = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -225,10 +226,11 @@ char *set_gpu_map(char *arg) return NULL; } -char *set_gpu_threads(char *arg) +char *set_gpu_threads(const char *_arg) { int i, val = 1, device = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -254,10 +256,11 @@ char *set_gpu_threads(char *arg) return NULL; } -char *set_gpu_engine(char *arg) +char *set_gpu_engine(const char *_arg) { int i, val1 = 0, val2 = 0, device = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -325,10 +328,11 @@ char *set_gpu_fan(char *arg) return NULL; } -char *set_gpu_memclock(char *arg) +char *set_gpu_memclock(const char *_arg) { int i, val = 0, device = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -509,10 +513,11 @@ char *set_temp_target(char *arg) } #endif -char *set_intensity(char *arg) +char *set_intensity(const char *_arg) { int i, device = 0, *tt; char *nextptr, val = 0; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -562,10 +567,11 @@ char *set_intensity(char *arg) return NULL; } -char *set_xintensity(char *arg) +char *set_xintensity(const char *_arg) { int i, device = 0, val = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -603,10 +609,11 @@ char *set_xintensity(char *arg) return NULL; } -char *set_rawintensity(char *arg) +char *set_rawintensity(const char *_arg) { int i, device = 0, val = 0; char *nextptr; + char *arg = strdupa(_arg); nextptr = strtok(arg, ","); if (nextptr == NULL) @@ -1403,7 +1410,6 @@ static void opencl_thread_shutdown(struct thr_info *thr) { const int thr_id = thr->id; _clState *clState = clStates[thr_id]; - cl_kernel *kernel = clState->extra_kernels; clStates[thr_id] = NULL; unsigned int i; diff --git a/driver-opencl.h b/driver-opencl.h index 6c5b2009..4ddcb5df 100644 --- a/driver-opencl.h +++ b/driver-opencl.h @@ -7,23 +7,23 @@ extern void print_ndevs(int *ndevs); extern void *reinit_gpu(void *userdata); extern char *set_gpu_map(char *arg); -extern char *set_gpu_threads(char *arg); -extern char *set_gpu_engine(char *arg); +extern char *set_gpu_threads(const char *arg); +extern char *set_gpu_engine(const char *arg); extern char *set_gpu_fan(char *arg); -extern char *set_gpu_memclock(char *arg); +extern char *set_gpu_memclock(const char *arg); extern char *set_gpu_memdiff(char *arg); extern char *set_gpu_powertune(char *arg); extern char *set_gpu_vddc(char *arg); extern char *set_temp_overheat(char *arg); extern char *set_temp_target(char *arg); -extern char *set_intensity(char *arg); -extern char *set_xintensity(char *arg); -extern char *set_rawintensity(char *arg); +extern char *set_intensity(const char *arg); +extern char *set_xintensity(const char *arg); +extern char *set_rawintensity(const char *arg); extern char *set_vector(char *arg); extern char *set_worksize(char *arg); extern char *set_shaders(char *arg); extern char *set_lookup_gap(char *arg); -extern char *set_thread_concurrency(char *arg); +extern char *set_thread_concurrency(const char *arg); void manage_gpu(void); extern void pause_dynamic_threads(int gpu); diff --git a/fuguecoin.c b/fuguecoin.c index 2fe3d0d4..cc252633 100644 --- a/fuguecoin.c +++ b/fuguecoin.c @@ -63,11 +63,9 @@ int fuguecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); fuguehash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -85,7 +83,6 @@ int fuguecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t void fuguecoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -100,7 +97,6 @@ bool scanhash_fuguecoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/groestlcoin.c b/groestlcoin.c index 48fe829a..b49f5ada 100644 --- a/groestlcoin.c +++ b/groestlcoin.c @@ -54,7 +54,6 @@ be32enc_vect(uint32_t *dst, const uint32_t *src, uint32_t len) inline void groestlhash(void *state, const void *input) { sph_groestl512_context ctx_groestl; - sph_sha256_context ctx_sha2; uint32_t hash[16]; @@ -77,11 +76,9 @@ int groestlcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_ { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); groestlhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -99,7 +96,6 @@ int groestlcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_ void groestlcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -114,7 +110,6 @@ bool scanhash_groestlcoin(struct thr_info *thr, const unsigned char __maybe_unus uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/inkcoin.c b/inkcoin.c index 011f7af9..c0470550 100644 --- a/inkcoin.c +++ b/inkcoin.c @@ -114,11 +114,9 @@ int inkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); inkhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -136,7 +134,6 @@ int inkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no void inkcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -198,7 +195,6 @@ bool scanhash_inkcoin(struct thr_info *thr, const unsigned char __maybe_unused * uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/marucoin.c b/marucoin.c index 10482de3..d54b8f2d 100644 --- a/marucoin.c +++ b/marucoin.c @@ -162,11 +162,9 @@ int marucoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t n { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); maruhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -184,7 +182,6 @@ int marucoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t n void marucoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -199,7 +196,6 @@ bool scanhash_marucoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/myriadcoin-groestl.c b/myriadcoin-groestl.c index 8d627ced..e37c5a50 100644 --- a/myriadcoin-groestl.c +++ b/myriadcoin-groestl.c @@ -77,11 +77,9 @@ int myriadcoin_groestl_test(unsigned char *pdata, const unsigned char *ptarget, { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); mghash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -99,7 +97,6 @@ int myriadcoin_groestl_test(unsigned char *pdata, const unsigned char *ptarget, void myriadcoin_groestl_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -114,7 +111,6 @@ bool scanhash_myriadcoin_groestl(struct thr_info *thr, const unsigned char __may uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/quarkcoin.c b/quarkcoin.c index 68590dfc..837a4cc3 100644 --- a/quarkcoin.c +++ b/quarkcoin.c @@ -149,11 +149,9 @@ int quarkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); quarkhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -171,7 +169,6 @@ int quarkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t void quarkcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -186,7 +183,6 @@ bool scanhash_quarkcoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/qubitcoin.c b/qubitcoin.c index 6127519c..e6685153 100644 --- a/qubitcoin.c +++ b/qubitcoin.c @@ -113,11 +113,9 @@ int qubitcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); qhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -135,7 +133,6 @@ int qubitcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t void qubitcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -150,7 +147,6 @@ bool scanhash_qubitcoin(struct thr_info *thr, const unsigned char __maybe_unused uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/sgminer.c b/sgminer.c index 5e2f117f..676abbb0 100644 --- a/sgminer.c +++ b/sgminer.c @@ -1190,11 +1190,10 @@ static char *set_null(const char __maybe_unused *arg) char *set_difficulty_multiplier(char *arg) { - char **endptr = NULL; if (!(arg && arg[0])) return "Invalid parameters for set difficulty multiplier"; - opt_diff_mult = strtod(arg, endptr); - if (opt_diff_mult == 0 || endptr == arg) + opt_diff_mult = strtod(arg, NULL); + if (opt_diff_mult == 0.0) return "Invalid value passed to set difficulty multiplier"; return NULL; @@ -3352,7 +3351,7 @@ static #ifdef WIN32 const #endif -char **initial_args; +const char **initial_args; static void clean_up(bool restarting); @@ -6225,7 +6224,7 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) for (i = 0; i < total_devices; ++i) n_threads += devices[i]->threads; - if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, n_threads))) + if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *)n_threads))) quit(1, "restart_mining_threads create thread failed"); sleep(60); quit(1, "thread was not cancelled in 60 seconds after restart_mining_threads"); @@ -8143,8 +8142,7 @@ int main(int argc, char *argv[]) #endif struct thr_info *thr; struct block *block; - unsigned int k; - int i, j; + int i; char *s; /* This dangerous function tramples random dynamically allocated @@ -8160,7 +8158,7 @@ int main(int argc, char *argv[]) initial_args = (const char **)malloc(sizeof(char *)* (argc + 1)); for (i = 0; i < argc; i++) - initial_args[i] = strdup(argv[i]); + initial_args[i] = (const char *)strdup(argv[i]); initial_args[argc] = NULL; mutex_init(&hash_lock); diff --git a/sifcoin.c b/sifcoin.c index e7a64b63..3e19d8b3 100644 --- a/sifcoin.c +++ b/sifcoin.c @@ -104,11 +104,9 @@ int sifcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); sifhash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -126,7 +124,6 @@ int sifcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no void sifcoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -141,7 +138,6 @@ bool scanhash_sifcoin(struct thr_info *thr, const unsigned char __maybe_unused * uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/twecoin.c b/twecoin.c index 2c9996ba..cb5583f5 100644 --- a/twecoin.c +++ b/twecoin.c @@ -90,11 +90,9 @@ int twecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no { uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); uint32_t data[20], ohash[8]; - //char *scratchbuf; be32enc_vect(data, (const uint32_t *)pdata, 19); data[19] = htobe32(nonce); - //scratchbuf = alloca(SCRATCHBUF_SIZE); twehash(ohash, data); tmp_hash7 = be32toh(ohash[7]); @@ -112,7 +110,6 @@ int twecoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no void twecoin_regenhash(struct work *work) { uint32_t data[20]; - char *scratchbuf; uint32_t *nonce = (uint32_t *)(work->data + 76); uint32_t *ohash = (uint32_t *)(work->hash); @@ -127,7 +124,6 @@ bool scanhash_twecoin(struct thr_info *thr, const unsigned char __maybe_unused * uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) { uint32_t *nonce = (uint32_t *)(pdata + 76); - char *scratchbuf; uint32_t data[20]; uint32_t tmp_hash7; uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); diff --git a/util.c b/util.c index e160b66e..d2c94829 100644 --- a/util.c +++ b/util.c @@ -1671,7 +1671,7 @@ static bool parse_diff(struct pool *pool, json_t *val) static bool parse_extranonce(struct pool *pool, json_t *val) { - char s[RBUFSIZE], *nonce1; + char *nonce1; int n2size; nonce1 = json_array_string(val, 0); diff --git a/util.h b/util.h index fbd8bf1b..364f8163 100644 --- a/util.h +++ b/util.h @@ -137,6 +137,7 @@ char *recv_line(struct pool *pool); bool parse_method(struct pool *pool, char *s); bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port); bool auth_stratum(struct pool *pool); +bool subscribe_extranonce(struct pool *pool); bool initiate_stratum(struct pool *pool); bool restart_stratum(struct pool *pool); void suspend_stratum(struct pool *pool);