Commit 4cd5f47efa235dccb7d489935a0359400d24e100

Con Kolivas 2011-06-23T21:09:22

Revert "Multiple compiler warning fixes." This reverts commit a5cbfbde2610e9f60e14b41a4e0595bcb34c772a. Broke.

diff --git a/cpu-miner.c b/cpu-miner.c
index 60a6b7a..007abd3 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -127,7 +127,7 @@ static enum sha256_algos opt_algo = ALGO_SSE2_64;
 #else
 static enum sha256_algos opt_algo = ALGO_C;
 #endif
-static unsigned int nDevs;
+static int nDevs;
 static int opt_n_threads = 1;
 static int num_processors;
 static int scan_intensity = 5;
@@ -642,7 +642,7 @@ static void *miner_thread(void *userdata)
 	/* Cpu affinity only makes sense if the number of threads is a multiple
 	 * of the number of CPUs */
 	if (!(opt_n_threads % num_processors))
-		affine_to_cpu(thr_id - nDevs, thr_id % num_processors);
+		affine_to_cpu(mythr->id, mythr->id % num_processors);
 
 	while (1) {
 		struct work work __attribute__((aligned(128)));
@@ -671,7 +671,7 @@ static void *miner_thread(void *userdata)
 
 #ifdef WANT_X8664_SSE2
 		case ALGO_SSE2_64: {
-			int rc5 =
+			unsigned int rc5 =
 			        scanhash_sse2_64(thr_id, work.midstate, work.data + 64,
 						 work.hash1, work.hash,
 						 work.target,
@@ -683,7 +683,7 @@ static void *miner_thread(void *userdata)
 
 #ifdef WANT_SSE2_4WAY
 		case ALGO_4WAY: {
-			int rc4 =
+			unsigned int rc4 =
 				ScanHash_4WaySSE2(thr_id, work.midstate, work.data + 64,
 						  work.hash1, work.hash,
 						  work.target,
@@ -907,7 +907,7 @@ out:
 
 static void restart_threads(void)
 {
-	unsigned int i;
+	int i;
 
 	for (i = 0; i < opt_n_threads + nDevs; i++)
 		work_restart[i].restart = 1;
@@ -988,7 +988,7 @@ out:
 
 static void show_usage(void)
 {
-	unsigned int i;
+	int i;
 
 	printf("minerd version %s\n\n", VERSION);
 	printf("Usage:\tminerd [options]\n\nSupported options:\n");
@@ -1004,8 +1004,7 @@ static void show_usage(void)
 
 static void parse_arg (int key, char *arg)
 {
-	int v;
-	unsigned int i;
+	int v, i;
 
 	switch(key) {
 	case 'a':
@@ -1109,7 +1108,7 @@ static void parse_arg (int key, char *arg)
 
 static void parse_config(void)
 {
-	unsigned int i;
+	int i;
 	json_t *val;
 
 	if (!json_is_object(opt_config))
@@ -1157,7 +1156,7 @@ static void parse_cmdline(int argc, char *argv[])
 int main (int argc, char *argv[])
 {
 	struct thr_info *thr;
-	unsigned int i;
+	int i;
 	char name[32];
 
 #ifdef WIN32
diff --git a/findnonce.c b/findnonce.c
index 198c4c0..3c310fc 100644
--- a/findnonce.c
+++ b/findnonce.c
@@ -136,7 +136,7 @@ void postcalc_hash(struct thr_info *thr, dev_blk_ctx *blk, struct work *work, ui
 	cl_uint A, B, C, D, E, F, G, H;
 	cl_uint W[16];
 	cl_uint nonce;
-	cl_uint best_g = 0xFFFFFFFF;
+	cl_uint best_g = ~0;
 	uint32_t end = start + 1026;
 
 	for (nonce = start; nonce != end; nonce+=1) {
@@ -183,6 +183,6 @@ void postcalc_hash(struct thr_info *thr, dev_blk_ctx *blk, struct work *work, ui
 		}
 	}
 out:
-	if (unlikely(best_g == 0xFFFFFFFF))
+	if (unlikely(best_g == ~0))
 		applog(LOG_ERR, "No best_g found! Error in OpenCL code?");
 }
diff --git a/ocl.c b/ocl.c
index 96fa704..5f29fd9 100644
--- a/ocl.c
+++ b/ocl.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
@@ -155,7 +154,7 @@ void patch_opcodes(char *w, unsigned remaining)
 	}
 }
 
-_clState *initCl(unsigned int gpu, char *name, size_t nameSize)
+_clState *initCl(int gpu, char *name, size_t nameSize)
 {
 	bool hasBitAlign = false;
 	cl_int status = 0;
@@ -242,7 +241,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 			printf("\t%i\t%s\n", i, pbuff);
 		}
 
-		if (gpu < numDevices) {
+		if (gpu >= 0 && gpu < numDevices) {
 			char pbuff[100];
 			status = clGetDeviceInfo(devices[gpu], CL_DEVICE_NAME, sizeof(pbuff), pbuff, NULL);
 			if(status != CL_SUCCESS)
diff --git a/ocl.h b/ocl.h
index f22d649..5c2e9dd 100644
--- a/ocl.h
+++ b/ocl.h
@@ -16,7 +16,7 @@ typedef struct {
 
 extern char *file_contents(const char *filename, int *length);
 extern int clDevicesNum();
-extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize);
+extern _clState *initCl(int gpu, char *name, size_t nameSize);
 extern cl_uint preferred_vwidth;
 extern size_t max_work_size;
 
diff --git a/util.c b/util.c
index c47f1b3..b6c3c60 100644
--- a/util.c
+++ b/util.c
@@ -72,7 +72,7 @@ void applog(int prio, const char *fmt, ...)
 	else {
 		char *f;
 		int len;
-		struct timeval tv;
+		struct timeval tv = { };
 		struct tm tm, *tm_p;
 
 		gettimeofday(&tv, NULL);
@@ -135,7 +135,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;
@@ -205,14 +205,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 * 10);
-	struct header_info hi ;
+	struct header_info hi = { };
 	bool lp_scanning = false;
 
 	/* it is assumed that 'curl' is freshly [re]initialized at this pt */
@@ -323,7 +323,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;