Skip to content

Commit 8fec16b

Browse files
authored
Merge pull request #280 from obilaniu/gccwarnings
Eliminate nearly all GCC warnings under -Wall -Wextra -Wno-unused-parameter.
2 parents 8e6df64 + 111819f commit 8fec16b

5 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/gpuarray_array.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ int GpuArray_index_inplace(GpuArray *a, const ssize_t *starts,
280280
return GA_VALUE_ERROR;
281281
}
282282
if (steps[i] == 0 &&
283-
(starts[i] == -1 || starts[i] >= a->dimensions[i])) {
283+
(starts[i] == -1 || (size_t)starts[i] >= a->dimensions[i])) {
284284
free(newdims);
285285
free(newstrs);
286286
return GA_VALUE_ERROR;
@@ -663,10 +663,10 @@ int GpuArray_reshape_inplace(GpuArray *a, unsigned int nd,
663663

664664
for (ok = oi; ok < oj - 1; ok++) {
665665
if (ord == GA_F_ORDER) {
666-
if (a->strides[ok+1] != a->dimensions[ok]*a->strides[ok])
666+
if (a->strides[ok+1] != (ssize_t)a->dimensions[ok]*a->strides[ok])
667667
goto need_copy;
668668
} else {
669-
if (a->strides[ok] != a->dimensions[ok+1]*a->strides[ok+1])
669+
if (a->strides[ok] != (ssize_t)a->dimensions[ok+1]*a->strides[ok+1])
670670
goto need_copy;
671671
}
672672
}
@@ -1125,7 +1125,7 @@ int GpuArray_is_c_contiguous(const GpuArray *a) {
11251125
int i;
11261126

11271127
for (i = a->nd - 1; i >= 0; i--) {
1128-
if (a->strides[i] != size) return 0;
1128+
if (a->strides[i] != (ssize_t)size) return 0;
11291129
// We suppose that overflow will not happen since data has to fit in memory
11301130
size *= a->dimensions[i];
11311131
}
@@ -1137,7 +1137,7 @@ int GpuArray_is_f_contiguous(const GpuArray *a) {
11371137
unsigned int i;
11381138

11391139
for (i = 0; i < a->nd; i++) {
1140-
if (a->strides[i] != size) return 0;
1140+
if (a->strides[i] != (ssize_t)size) return 0;
11411141
// We suppose that overflow will not happen since data has to fit in memory
11421142
size *= a->dimensions[i];
11431143
}

src/gpuarray_array_blas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
370370
int err;
371371
gpudata **A_datas = NULL, **B_datas = NULL, **C_datas = NULL;
372372
size_t *A_offsets = NULL, *B_offsets = NULL, *C_offsets = NULL;
373-
int i;
373+
size_t i;
374374

375375
if (A->typecode != GA_FLOAT && A->typecode != GA_DOUBLE)
376376
return GA_INVALID_ERROR;

src/gpuarray_buffer_cuda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ static int detect_arch(const char *prefix, char *ret, CUresult *err) {
871871
*err = get_cc(dev, &major, &minor);
872872
if (*err != CUDA_SUCCESS) return GA_IMPL_ERROR;
873873
res = snprintf(ret, sz, "%s%d%d", prefix, major, minor);
874-
if (res == -1 || res > sz) return GA_UNSUPPORTED_ERROR;
874+
if (res == -1 || res > (ssize_t)sz) return GA_UNSUPPORTED_ERROR;
875875
return GA_NO_ERROR;
876876
}
877877

src/gpuarray_buffer_opencl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,11 +1453,12 @@ static int cl_property(gpucontext *c, gpudata *buf, gpukernel *k, int prop_id,
14531453

14541454
static const char *cl_error(gpucontext *c) {
14551455
cl_ctx *ctx = (cl_ctx *)c;
1456-
if (ctx == NULL)
1456+
if (ctx == NULL){
14571457
return get_error_string(err);
1458-
else
1458+
}else{
14591459
ASSERT_CTX(ctx);
14601460
return get_error_string(ctx->err);
1461+
}
14611462
}
14621463

14631464
GPUARRAY_LOCAL

src/gpuarray_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void gpuarray_elemwise_collapse(unsigned int n, unsigned int *_nd,
173173
int collapse = 1;
174174
for (k = 0; k < n; k++) {
175175
collapse &= (strs[k] == NULL ||
176-
strs[k][i - 1] == dims[i] * strs[k][i]);
176+
strs[k][i - 1] == (ssize_t)dims[i] * strs[k][i]);
177177
}
178178
if (collapse) {
179179
dims[i-1] *= dims[i];

0 commit comments

Comments
 (0)