Fix harmless warnings with -Wsign-compare to allow cgminer to build with -W.
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
diff --git a/bitforce.c b/bitforce.c
index bd1a562..2bba7c5 100644
--- a/bitforce.c
+++ b/bitforce.c
@@ -61,9 +61,10 @@ static void BFgets(char *buf, size_t bufLen, int fd)
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);
+
if (unlikely(ret != bufLen))
quit(1, "BFwrite failed");
}
diff --git a/cgminer.c b/cgminer.c
index 7cf1a91..20e1d2f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -410,6 +410,7 @@ static char *add_serial(char *arg)
static char *set_devices(char *arg)
{
int i = strtol(arg, &arg, 0);
+
if (*arg) {
if (*arg == '?') {
devices_enabled = -1;
@@ -418,7 +419,7 @@ static char *set_devices(char *arg)
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";
devices_enabled |= 1 << i;
return NULL;
@@ -1660,7 +1661,7 @@ static void print_summary(void);
void kill_work(void)
{
struct thr_info *thr;
- unsigned int i;
+ int i;
disable_curses();
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 */
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 diff, sdiff, wdiff;
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;
struct sigaction handler;
struct thr_info *thr;
- unsigned int i, j, k;
+ unsigned int k;
+ int i, j;
/* This dangerous functions tramples random dynamically allocated
* variables so do it before anything at all */
@@ -4243,7 +4245,7 @@ int main (int argc, char *argv[])
mining_threads = 0;
gpu_threads = 0;
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 (i >= total_devices)
quit (1, "Command line options set a device that doesn't exist");
diff --git a/device-gpu.c b/device-gpu.c
index e9c9d78..242cb51 100644
--- a/device-gpu.c
+++ b/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_kernel *kernel = &clState->kernel;
+ unsigned int i, num = 0;
cl_int status = 0;
- int i, num = 0;
uint *nonces;
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_kernel *kernel = &clState->kernel;
+ unsigned int i, num = 0;
cl_int status = 0;
- int i, num = 0;
uint *nonces;
nonces = alloca(sizeof(uint) * vwidth);
diff --git a/ocl.c b/ocl.c
index 0c1b059..5acb07f 100644
--- a/ocl.c
+++ b/ocl.c
@@ -206,7 +206,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
return NULL;
}
- if (opt_platform_id >= numPlatforms) {
+ if (opt_platform_id >= (int)numPlatforms) {
applog(LOG_ERR, "Specified platform that does not exist");
return NULL;
}
@@ -340,7 +340,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
if (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;
else
clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) /
diff --git a/util.c b/util.c
index 1b073e3..2b5adf6 100644
--- a/util.c
+++ b/util.c
@@ -104,7 +104,7 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
void *user_data)
{
struct upload_buffer *ub = user_data;
- int len = size * nmemb;
+ unsigned int len = size * nmemb;
if (len > ub->len)
len = ub->len;
@@ -429,8 +429,9 @@ err_out:
char *bin2hex(const unsigned char *p, size_t len)
{
- int i;
+ unsigned int i;
char *s = malloc((len * 2) + 1);
+
if (!s)
return NULL;