Revert "Fix various harmless warnings." This reverts commit a4b67f030fc0c7e2b18e79114a441c1e1617d5f8.
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
diff --git a/adl.c b/adl.c
index dc3f820..aad827b 100644
--- a/adl.c
+++ b/adl.c
@@ -936,7 +936,7 @@ static int set_powertune(int gpu, int iPercentage)
return ret;
}
-static void fan_autotune(int gpu, int temp, int fanpercent, __maybe_unused bool *fan_optimal)
+static void fan_autotune(int gpu, int temp, int fanpercent, bool *fan_optimal)
{
struct cgpu_info *cgpu = &gpus[gpu];
struct gpu_adl *ga = &cgpu->adl;
@@ -1244,7 +1244,7 @@ updated:
goto updated;
}
-void clear_adl(int nDevs)
+void clear_adl(nDevs)
{
struct gpu_adl *ga;
int i;
diff --git a/main.c b/main.c
index eece12c..0995172 100644
--- a/main.c
+++ b/main.c
@@ -181,7 +181,7 @@ int opt_log_interval = 5;
bool opt_log_output = false;
static int opt_queue = 1;
int opt_vectors;
-unsigned int opt_worksize;
+int opt_worksize;
int opt_scantime = 60;
int opt_expiry = 120;
int opt_bench_algo = -1;
@@ -997,18 +997,15 @@ static char *set_float_0_to_99(const char *arg, float *f)
return NULL;
}
-#ifdef USE_BITFORCE
static char *add_serial(char *arg)
{
string_elist_add(arg, &scan_devices);
return NULL;
}
-#endif
static char *set_devices(char *arg)
{
int i = strtol(arg, &arg, 0);
-
if (*arg) {
if (*arg == '?') {
devices_enabled = -1;
@@ -1017,7 +1014,7 @@ static char *set_devices(char *arg)
return "Invalid device number";
}
- if (i < 0 || i >= (int)(sizeof(devices_enabled) * 8) - 1)
+ if (i < 0 || i >= (sizeof(devices_enabled) * 8) - 1)
return "Invalid device number";
devices_enabled |= 1 << i;
return NULL;
@@ -1806,7 +1803,7 @@ static char *parse_config(json_t *config, bool fileconf)
return NULL;
}
-static char *load_config(const char *arg, __maybe_unused void *unused)
+static char *load_config(const char *arg, void *unused)
{
json_error_t err;
json_t *config;
@@ -2583,7 +2580,7 @@ static void print_summary(void);
void kill_work(void)
{
struct thr_info *thr;
- int i;
+ unsigned int i;
disable_curses();
applog(LOG_INFO, "Received kill message");
@@ -3776,7 +3773,7 @@ static void manage_gpu(void)
}
#endif
-static void *input_thread(__maybe_unused void *userdata)
+static void *input_thread(void *userdata)
{
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
@@ -4162,8 +4159,7 @@ static void roll_work(struct work *work)
/* Recycle the work at a higher starting res_nonce if we know the thread we're
* giving it to will not finish scanning it. We keep the master copy to be
* recycled more rapidly and discard the clone to avoid repeating work */
-static bool divide_work(__maybe_unused struct timeval *now, struct work *work,
- __maybe_unused uint32_t hash_div)
+static bool divide_work(struct timeval *now, struct work *work, uint32_t hash_div)
{
if (can_roll(work) && should_roll(work)) {
roll_work(work);
@@ -4198,7 +4194,7 @@ static bool get_work(struct work *work, bool requested, struct thr_info *thr,
const int thr_id, uint32_t hash_div)
{
bool newreq = false, ret = false;
- struct timespec abstime;
+ struct timespec abstime = {};
struct timeval now;
struct work *work_heap;
struct pool *pool;
@@ -4367,7 +4363,7 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
return submit_work_sync(thr, work);
}
-static inline bool abandon_work(struct work *work, struct timeval *wdiff, uint64_t hashes)
+static inline bool abandon_work(int thr_id, struct work *work, struct timeval *wdiff, uint64_t hashes)
{
if (wdiff->tv_sec > opt_scantime ||
work->blk.nonce >= MAXTHREADS - hashes ||
@@ -4386,7 +4382,7 @@ static void *miner_thread(void *userdata)
/* Try to cycle approximately 5 times before each log update */
const unsigned long def_cycle = opt_log_interval / 5 ? : 1;
- time_t cycle;
+ unsigned long cycle;
struct timeval tv_start, tv_end, tv_workstart, tv_lastupdate;
struct timeval diff, sdiff, wdiff;
uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
@@ -4422,7 +4418,7 @@ static void *miner_thread(void *userdata)
cycle = (can_roll(work) && should_roll(work)) ? 1 : def_cycle;
gettimeofday(&tv_workstart, NULL);
work->blk.nonce = 0;
- if (api->prepare_work && !api->prepare_work(work)) {
+ if (api->prepare_work && !api->prepare_work(mythr, work)) {
applog(LOG_ERR, "work prepare failed, exiting "
"mining thread %d", thr_id);
break;
@@ -4504,7 +4500,7 @@ static void *miner_thread(void *userdata)
if (can_roll(work) && should_roll(work))
roll_work(work);
- } while (!abandon_work(work, &wdiff, hashes));
+ } while (!abandon_work(thr_id, work, &wdiff, hashes));
}
out:
@@ -4569,8 +4565,7 @@ static cl_int queue_phatk_kernel(_clState *clState, dev_blk_ctx *blk)
cl_uint vwidth = clState->preferred_vwidth;
cl_kernel *kernel = &clState->kernel;
cl_int status = 0;
- unsigned int i;
- int num = 0;
+ int i, num = 0;
uint *nonces;
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->ctx_a);
@@ -4911,7 +4906,7 @@ void reinit_device(struct cgpu_info *cgpu)
/* Makes sure the hashmeter keeps going even if mining threads stall, updates
* the screen at regular intervals, and restarts threads if they appear to have
* died. */
-static void *watchdog_thread(__maybe_unused void *userdata)
+static void *watchdog_thread(void *userdata)
{
const unsigned int interval = 3;
static struct timeval rotate_tv;
@@ -5714,14 +5709,13 @@ static void opencl_free_work(struct thr_info *thr, struct work *work)
}
}
-static bool opencl_prepare_work(struct work *work)
+static bool opencl_prepare_work(struct thr_info *thr, struct work *work)
{
precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
return true;
}
-static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work,
- __maybe_unused uint64_t max_nonce)
+static uint64_t opencl_scanhash(struct thr_info *thr, struct work *work, uint64_t max_nonce)
{
const int thr_id = thr->id;
struct opencl_thread_data *thrdata = thr->cgpu_data;
@@ -5861,13 +5855,12 @@ void enable_device(struct cgpu_info *cgpu)
int main (int argc, char *argv[])
{
- unsigned pools_active = 0;
+ unsigned int i, pools_active = 0;
+ unsigned int j, k;
struct block *block, *tmpblock;
struct work *work, *tmpwork;
struct sigaction handler;
struct thr_info *thr;
- unsigned int k;
- int i, j;
/* This dangerous functions tramples random dynamically allocated
* variables so do it before anything at all */
@@ -6006,7 +5999,7 @@ int main (int argc, char *argv[])
mining_threads = 0;
gpu_threads = 0;
if (devices_enabled) {
- for (i = 0; i < (int)(sizeof(devices_enabled) * 8) - 1; ++i) {
+ for (i = 0; i < (sizeof(devices_enabled) * 8) - 1; ++i) {
if (devices_enabled & (1 << i)) {
if (i >= total_devices)
quit (1, "Command line options set a device that doesn't exist");
diff --git a/miner.h b/miner.h
index e4fca3c..d91b82f 100644
--- a/miner.h
+++ b/miner.h
@@ -147,7 +147,6 @@ enum {
#define unlikely(expr) (expr)
#define likely(expr) (expr)
#endif
-#define __maybe_unused __attribute__((unused))
#if defined(__i386__)
#define WANT_CRYPTOPP_ASM32
@@ -251,7 +250,7 @@ struct device_api {
uint64_t (*can_limit_work)(struct thr_info*);
bool (*thread_init)(struct thr_info*);
void (*free_work)(struct thr_info*, struct work*);
- bool (*prepare_work)(struct work*);
+ bool (*prepare_work)(struct thr_info*, struct work*);
uint64_t (*scanhash)(struct thr_info*, struct work*, uint64_t);
void (*thread_shutdown)(struct thr_info*);
};
diff --git a/ocl.c b/ocl.c
index 91b0aa7..16d1a1e 100644
--- a/ocl.c
+++ b/ocl.c
@@ -28,7 +28,7 @@
#include "ocl.h"
extern int opt_vectors;
-extern unsigned int opt_worksize;
+extern int opt_worksize;
char *file_contents(const char *filename, int *length)
{
diff --git a/util.c b/util.c
index b43e4aa..aab5070 100644
--- a/util.c
+++ b/util.c
@@ -78,7 +78,7 @@ void vapplog(int prio, const char *fmt, va_list ap)
else if (opt_log_output || prio <= LOG_NOTICE) {
char *f;
int len;
- struct timeval tv;
+ struct timeval tv = { };
struct tm tm;
gettimeofday(&tv, NULL);
@@ -163,7 +163,7 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
void *user_data)
{
struct upload_buffer *ub = user_data;
- unsigned int len = size * nmemb;
+ int len = size * nmemb;
if (len > ub->len)
len = ub->len;
@@ -239,7 +239,7 @@ out:
}
#ifdef CURL_HAS_SOCKOPT
-int json_rpc_call_sockopt_cb(__maybe_unused void *userdata, curl_socket_t fd, __maybe_unused curlsocktype purpose)
+int json_rpc_call_sockopt_cb(void *userdata, curl_socket_t fd, curlsocktype purpose)
{
int keepalive = 1;
int tcp_keepcnt = 5;
@@ -309,14 +309,14 @@ json_t *json_rpc_call(CURL *curl, const char *url,
{
json_t *val, *err_val, *res_val;
int rc;
- struct data_buffer all_data;
+ struct data_buffer all_data = { };
struct upload_buffer upload_data;
- json_error_t err;
+ json_error_t err = { };
struct curl_slist *headers = NULL;
char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE];
long timeout = longpoll ? (60 * 60) : 60;
- struct header_info hi;
+ struct header_info hi = { };
bool probing = false;
/* it is assumed that 'curl' is freshly [re]initialized at this pt */
@@ -478,7 +478,7 @@ err_out:
char *bin2hex(const unsigned char *p, size_t len)
{
- unsigned int i;
+ int i;
char *s = malloc((len * 2) + 1);
if (!s)
return NULL;
@@ -730,7 +730,7 @@ void thr_info_cancel(struct thr_info *thr)
bool get_dondata(char **url, char **userpass)
{
- struct data_buffer all_data ;
+ struct data_buffer all_data = { };
char curl_err_str[CURL_ERROR_SIZE];
CURL *curl = curl_easy_init();
int rc;