Browse Source

Fix harmless warnings with -Wsign-compare to allow cgminer to build with -W.

Con Kolivas 14 years ago
parent
commit
56907db2d6
5 changed files with 16 additions and 12 deletions
  1. 2 1
      bitforce.c
  2. 7 5
      cgminer.c
  3. 2 2
      device-gpu.c
  4. 2 2
      ocl.c
  5. 3 2
      util.c

+ 2 - 1
bitforce.c

@@ -61,9 +61,10 @@ static void BFgets(char *buf, size_t bufLen, int fd)
 	buf[0] = '\0';
 	buf[0] = '\0';
 }
 }
 
 
-static void BFwrite(int fd, const void *buf, size_t bufLen)
+static void BFwrite(int fd, const void *buf, ssize_t bufLen)
 {
 {
 	ssize_t ret = write(fd, buf, bufLen);
 	ssize_t ret = write(fd, buf, bufLen);
+
 	if (unlikely(ret != bufLen))
 	if (unlikely(ret != bufLen))
 		quit(1, "BFwrite failed");
 		quit(1, "BFwrite failed");
 }
 }

+ 7 - 5
cgminer.c

@@ -410,6 +410,7 @@ static char *add_serial(char *arg)
 static char *set_devices(char *arg)
 static char *set_devices(char *arg)
 {
 {
 	int i = strtol(arg, &arg, 0);
 	int i = strtol(arg, &arg, 0);
+
 	if (*arg) {
 	if (*arg) {
 		if (*arg == '?') {
 		if (*arg == '?') {
 			devices_enabled = -1;
 			devices_enabled = -1;
@@ -418,7 +419,7 @@ static char *set_devices(char *arg)
 		return "Invalid device number";
 		return "Invalid device number";
 	}
 	}
 
 
-	if (i < 0 || i >= (sizeof(devices_enabled) * 8) - 1)
+	if (i < 0 || i >= (int)(sizeof(devices_enabled) * 8) - 1)
 		return "Invalid device number";
 		return "Invalid device number";
 	devices_enabled |= 1 << i;
 	devices_enabled |= 1 << i;
 	return NULL;
 	return NULL;
@@ -1660,7 +1661,7 @@ static void print_summary(void);
 void kill_work(void)
 void kill_work(void)
 {
 {
 	struct thr_info *thr;
 	struct thr_info *thr;
-	unsigned int i;
+	int i;
 
 
 	disable_curses();
 	disable_curses();
 	applog(LOG_INFO, "Received kill message");
 	applog(LOG_INFO, "Received kill message");
@@ -3255,7 +3256,7 @@ void *miner_thread(void *userdata)
 
 
 	/* Try to cycle approximately 5 times before each log update */
 	/* Try to cycle approximately 5 times before each log update */
 	const unsigned long def_cycle = opt_log_interval / 5 ? : 1;
 	const unsigned long def_cycle = opt_log_interval / 5 ? : 1;
-	unsigned long cycle;
+	long cycle;
 	struct timeval tv_start, tv_end, tv_workstart, tv_lastupdate;
 	struct timeval tv_start, tv_end, tv_workstart, tv_lastupdate;
 	struct timeval diff, sdiff, wdiff;
 	struct timeval diff, sdiff, wdiff;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
 	uint32_t max_nonce = api->can_limit_work ? api->can_limit_work(mythr) : 0xffffffff;
@@ -4104,7 +4105,8 @@ int main (int argc, char *argv[])
 	bool pools_active = false;
 	bool pools_active = false;
 	struct sigaction handler;
 	struct sigaction handler;
 	struct thr_info *thr;
 	struct thr_info *thr;
-	unsigned int i, j, k;
+	unsigned int k;
+	int i, j;
 
 
 	/* This dangerous functions tramples random dynamically allocated
 	/* This dangerous functions tramples random dynamically allocated
 	 * variables so do it before anything at all */
 	 * variables so do it before anything at all */
@@ -4243,7 +4245,7 @@ int main (int argc, char *argv[])
 	mining_threads = 0;
 	mining_threads = 0;
 	gpu_threads = 0;
 	gpu_threads = 0;
 	if (devices_enabled) {
 	if (devices_enabled) {
-		for (i = 0; i < (sizeof(devices_enabled) * 8) - 1; ++i) {
+		for (i = 0; i < (int)(sizeof(devices_enabled) * 8) - 1; ++i) {
 			if (devices_enabled & (1 << i)) {
 			if (devices_enabled & (1 << i)) {
 				if (i >= total_devices)
 				if (i >= total_devices)
 					quit (1, "Command line options set a device that doesn't exist");
 					quit (1, "Command line options set a device that doesn't exist");

+ 2 - 2
device-gpu.c

@@ -689,8 +689,8 @@ static cl_int queue_phatk_kernel(_clState *clState, dev_blk_ctx *blk)
 {
 {
 	cl_uint vwidth = clState->preferred_vwidth;
 	cl_uint vwidth = clState->preferred_vwidth;
 	cl_kernel *kernel = &clState->kernel;
 	cl_kernel *kernel = &clState->kernel;
+	unsigned int i, num = 0;
 	cl_int status = 0;
 	cl_int status = 0;
-	int i, num = 0;
 	uint *nonces;
 	uint *nonces;
 
 
 	CL_SET_BLKARG(ctx_a);
 	CL_SET_BLKARG(ctx_a);
@@ -732,8 +732,8 @@ static cl_int queue_diakgcn_kernel(_clState *clState, dev_blk_ctx *blk)
 {
 {
 	cl_uint vwidth = clState->preferred_vwidth;
 	cl_uint vwidth = clState->preferred_vwidth;
 	cl_kernel *kernel = &clState->kernel;
 	cl_kernel *kernel = &clState->kernel;
+	unsigned int i, num = 0;
 	cl_int status = 0;
 	cl_int status = 0;
-	int i, num = 0;
 	uint *nonces;
 	uint *nonces;
 
 
 	nonces = alloca(sizeof(uint) * vwidth);
 	nonces = alloca(sizeof(uint) * vwidth);

+ 2 - 2
ocl.c

@@ -206,7 +206,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 		return NULL;
 		return NULL;
 	}
 	}
 
 
-	if (opt_platform_id >= numPlatforms) {
+	if (opt_platform_id >= (int)numPlatforms) {
 		applog(LOG_ERR, "Specified platform that does not exist");
 		applog(LOG_ERR, "Specified platform that does not exist");
 		return NULL;
 		return NULL;
 	}
 	}
@@ -340,7 +340,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 
 
 	if (opt_vectors)
 	if (opt_vectors)
 		clState->preferred_vwidth = opt_vectors;
 		clState->preferred_vwidth = opt_vectors;
-	if (opt_worksize && opt_worksize <= clState->max_work_size)
+	if (opt_worksize && opt_worksize <= (int)clState->max_work_size)
 		clState->work_size = opt_worksize;
 		clState->work_size = opt_worksize;
 	else
 	else
 		clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) /
 		clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) /

+ 3 - 2
util.c

@@ -104,7 +104,7 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
 			     void *user_data)
 			     void *user_data)
 {
 {
 	struct upload_buffer *ub = user_data;
 	struct upload_buffer *ub = user_data;
-	int len = size * nmemb;
+	unsigned int len = size * nmemb;
 
 
 	if (len > ub->len)
 	if (len > ub->len)
 		len = ub->len;
 		len = ub->len;
@@ -429,8 +429,9 @@ err_out:
 
 
 char *bin2hex(const unsigned char *p, size_t len)
 char *bin2hex(const unsigned char *p, size_t len)
 {
 {
-	int i;
+	unsigned int i;
 	char *s = malloc((len * 2) + 1);
 	char *s = malloc((len * 2) + 1);
+
 	if (!s)
 	if (!s)
 		return NULL;
 		return NULL;