diff --git a/src/grib_accessor_class_bufr_string_values.c b/src/grib_accessor_class_bufr_string_values.c index 88522299f..93c827e16 100644 --- a/src/grib_accessor_class_bufr_string_values.c +++ b/src/grib_accessor_class_bufr_string_values.c @@ -175,8 +175,8 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) grib_accessor* data = 0; grib_context* c = a->context; grib_vsarray* stringValues = NULL; - long l = 0, n = 0, tl; - size_t i, j; + size_t l = 0, tl; + size_t i, j, n = 0; /*char buf[25]={0,};*/ char** b = buffer; diff --git a/src/grib_accessor_class_g1end_of_interval_monthly.c b/src/grib_accessor_class_g1end_of_interval_monthly.c index ebd3b7260..30cc178d0 100644 --- a/src/grib_accessor_class_g1end_of_interval_monthly.c +++ b/src/grib_accessor_class_g1end_of_interval_monthly.c @@ -169,7 +169,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) if (!a->dirty) return GRIB_SUCCESS; - if (*len != self->number_of_elements) + if (*len != (size_t)self->number_of_elements) return GRIB_ARRAY_TOO_SMALL; if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) diff --git a/src/grib_bufr_descriptors_array.c b/src/grib_bufr_descriptors_array.c index bf51c5e3e..2e4898640 100644 --- a/src/grib_bufr_descriptors_array.c +++ b/src/grib_bufr_descriptors_array.c @@ -185,8 +185,8 @@ void grib_bufr_descriptors_array_delete(bufr_descriptors_array* v) void grib_bufr_descriptors_array_delete_array(bufr_descriptors_array* v) { - grib_context* c; - int i; + grib_context* c = NULL; + size_t i = 0; bufr_descriptor** vv = NULL; if (!v) diff --git a/src/grib_darray.c b/src/grib_darray.c index 71672421b..bc7c8dab1 100644 --- a/src/grib_darray.c +++ b/src/grib_darray.c @@ -108,8 +108,8 @@ void grib_darray_delete(grib_context* c, grib_darray* v) double* grib_darray_get_array(grib_context* c, grib_darray* v) { - double* ret; - int i; + double* ret = NULL; + size_t i = 0; if (!v) return NULL; ret = (double*)grib_context_malloc_clear(c, sizeof(double) * v->n); @@ -120,8 +120,8 @@ double* grib_darray_get_array(grib_context* c, grib_darray* v) int grib_darray_is_constant(grib_darray* v, double epsilon) { - int i; - double val; + size_t i = 0; + double val = 0; if (v->n == 1) return 1; diff --git a/src/grib_oarray.c b/src/grib_oarray.c index 6697e81a4..5e51751c5 100644 --- a/src/grib_oarray.c +++ b/src/grib_oarray.c @@ -102,8 +102,8 @@ void grib_oarray_delete_content(grib_context* c, grib_oarray* v) void** grib_oarray_get_array(grib_context* c, grib_oarray* v) { - void** ret; - int i; + void** ret = NULL; + size_t i = 0; if (!v) return NULL; ret = (void**)grib_context_malloc_clear(c, sizeof(char*) * v->n); @@ -114,7 +114,8 @@ void** grib_oarray_get_array(grib_context* c, grib_oarray* v) void* grib_oarray_get(grib_oarray* v, int i) { - if (v == NULL || i > v->n - 1) + DebugAssert(i >= 0); + if (v == NULL || (size_t)i > v->n - 1) return NULL; return v->v[i]; } diff --git a/src/grib_sarray.c b/src/grib_sarray.c index 869abde67..7ce3dcd9d 100644 --- a/src/grib_sarray.c +++ b/src/grib_sarray.c @@ -78,7 +78,7 @@ void grib_sarray_delete(grib_context* c, grib_sarray* v) void grib_sarray_delete_content(grib_context* c, grib_sarray* v) { - int i; + size_t i = 0; if (!v || !v->v) return; if (!c) @@ -93,8 +93,8 @@ void grib_sarray_delete_content(grib_context* c, grib_sarray* v) char** grib_sarray_get_array(grib_context* c, grib_sarray* v) { - char** ret; - int i; + char** ret = NULL; + size_t i = 0; if (!v) return NULL; ret = (char**)grib_context_malloc_clear(c, sizeof(char*) * v->n); diff --git a/src/grib_vdarray.c b/src/grib_vdarray.c index bce2d0ab0..4063eb19a 100644 --- a/src/grib_vdarray.c +++ b/src/grib_vdarray.c @@ -19,7 +19,7 @@ /* For debugging purposes */ void grib_vdarray_print(const char* title, const grib_vdarray* vdarray) { - size_t i; + size_t i = 0; char text[100] = {0,}; Assert(vdarray); printf("%s: vdarray.n=%lu\n", title, (unsigned long)vdarray->n); @@ -99,7 +99,7 @@ void grib_vdarray_delete(grib_context* c, grib_vdarray* v) void grib_vdarray_delete_content(grib_context* c, grib_vdarray* v) { - int i; + size_t i = 0; if (!v || !v->v) return; if (!c) @@ -114,7 +114,7 @@ void grib_vdarray_delete_content(grib_context* c, grib_vdarray* v) grib_darray** grib_vdarray_get_array(grib_context* c, grib_vdarray* v) { grib_darray** ret; - int i; + size_t i = 0; if (!v) return NULL; ret = (grib_darray**)grib_context_malloc_clear(c, sizeof(grib_darray*) * v->n); diff --git a/src/grib_viarray.c b/src/grib_viarray.c index 5c4f6692b..336e375bf 100644 --- a/src/grib_viarray.c +++ b/src/grib_viarray.c @@ -99,7 +99,7 @@ void grib_viarray_delete(grib_context* c, grib_viarray* v) void grib_viarray_delete_content(grib_context* c, grib_viarray* v) { - int i; + size_t i=0; if (!v || !v->v) return; @@ -113,7 +113,7 @@ void grib_viarray_delete_content(grib_context* c, grib_viarray* v) grib_iarray** grib_viarray_get_array(grib_context* c, grib_viarray* v) { grib_iarray** ret; - int i; + size_t i = 0; if (!v) return NULL; ret = (grib_iarray**)grib_context_malloc_clear(c, sizeof(grib_iarray*) * v->n); diff --git a/src/grib_vsarray.c b/src/grib_vsarray.c index 227aa41fc..26b88a9db 100644 --- a/src/grib_vsarray.c +++ b/src/grib_vsarray.c @@ -84,7 +84,7 @@ void grib_vsarray_delete(grib_context* c, grib_vsarray* v) void grib_vsarray_delete_content(grib_context* c, grib_vsarray* v) { - int i; + size_t i = 0; if (!v || !v->v) return; if (!c) @@ -100,7 +100,7 @@ void grib_vsarray_delete_content(grib_context* c, grib_vsarray* v) grib_sarray** grib_vsarray_get_array(grib_context* c, grib_vsarray* v) { grib_sarray** ret; - int i; + size_t i = 0; if (!v) return NULL; ret = (grib_sarray**)grib_context_malloc_clear(c, sizeof(grib_sarray*) * v->n); diff --git a/tools/grib_check_gaussian_grid.c b/tools/grib_check_gaussian_grid.c index 1b1024b57..54fa684f2 100644 --- a/tools/grib_check_gaussian_grid.c +++ b/tools/grib_check_gaussian_grid.c @@ -185,7 +185,7 @@ static int process_file(const char* filename) GRIB_CHECK(grib_get_size(h, "pl", &pl_len), 0); assert(pl_len > 0); - if (pl_len != 2 * N) { + if (pl_len != (size_t)(2 * N)) { error(filename, msg_num, "Length of pl array is %ld but should be 2*N (%ld)\n", pl_len, 2 * N); } pl = (long*)malloc(pl_len * sizeof(long)); @@ -232,7 +232,7 @@ static int process_file(const char* filename) } GRIB_CHECK(grib_get_size(h, "values", &sizeOfValuesArray), 0); - if (sizeOfValuesArray != numberOfDataPoints) { + if (sizeOfValuesArray != (size_t)numberOfDataPoints) { error(filename, msg_num, "Number of data points %d different from size of values array %d\n", numberOfDataPoints, sizeOfValuesArray); }