Compiler warnings: signed/unsigned mismatch

This commit is contained in:
Shahram Najm 2022-11-12 22:08:44 +00:00
parent f263f0567a
commit 1627cb06a7
10 changed files with 25 additions and 24 deletions

View File

@ -175,8 +175,8 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len)
grib_accessor* data = 0; grib_accessor* data = 0;
grib_context* c = a->context; grib_context* c = a->context;
grib_vsarray* stringValues = NULL; grib_vsarray* stringValues = NULL;
long l = 0, n = 0, tl; size_t l = 0, tl;
size_t i, j; size_t i, j, n = 0;
/*char buf[25]={0,};*/ /*char buf[25]={0,};*/
char** b = buffer; char** b = buffer;

View File

@ -169,7 +169,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (!a->dirty) if (!a->dirty)
return GRIB_SUCCESS; return GRIB_SUCCESS;
if (*len != self->number_of_elements) if (*len != (size_t)self->number_of_elements)
return GRIB_ARRAY_TOO_SMALL; return GRIB_ARRAY_TOO_SMALL;
if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS)

View File

@ -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) void grib_bufr_descriptors_array_delete_array(bufr_descriptors_array* v)
{ {
grib_context* c; grib_context* c = NULL;
int i; size_t i = 0;
bufr_descriptor** vv = NULL; bufr_descriptor** vv = NULL;
if (!v) if (!v)

View File

@ -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* grib_darray_get_array(grib_context* c, grib_darray* v)
{ {
double* ret; double* ret = NULL;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (double*)grib_context_malloc_clear(c, sizeof(double) * v->n); 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 grib_darray_is_constant(grib_darray* v, double epsilon)
{ {
int i; size_t i = 0;
double val; double val = 0;
if (v->n == 1) if (v->n == 1)
return 1; return 1;

View File

@ -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** grib_oarray_get_array(grib_context* c, grib_oarray* v)
{ {
void** ret; void** ret = NULL;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (void**)grib_context_malloc_clear(c, sizeof(char*) * v->n); 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) 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 NULL;
return v->v[i]; return v->v[i];
} }

View File

@ -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) void grib_sarray_delete_content(grib_context* c, grib_sarray* v)
{ {
int i; size_t i = 0;
if (!v || !v->v) if (!v || !v->v)
return; return;
if (!c) 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** grib_sarray_get_array(grib_context* c, grib_sarray* v)
{ {
char** ret; char** ret = NULL;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (char**)grib_context_malloc_clear(c, sizeof(char*) * v->n); ret = (char**)grib_context_malloc_clear(c, sizeof(char*) * v->n);

View File

@ -19,7 +19,7 @@
/* For debugging purposes */ /* For debugging purposes */
void grib_vdarray_print(const char* title, const grib_vdarray* vdarray) void grib_vdarray_print(const char* title, const grib_vdarray* vdarray)
{ {
size_t i; size_t i = 0;
char text[100] = {0,}; char text[100] = {0,};
Assert(vdarray); Assert(vdarray);
printf("%s: vdarray.n=%lu\n", title, (unsigned long)vdarray->n); 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) void grib_vdarray_delete_content(grib_context* c, grib_vdarray* v)
{ {
int i; size_t i = 0;
if (!v || !v->v) if (!v || !v->v)
return; return;
if (!c) 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** grib_vdarray_get_array(grib_context* c, grib_vdarray* v)
{ {
grib_darray** ret; grib_darray** ret;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (grib_darray**)grib_context_malloc_clear(c, sizeof(grib_darray*) * v->n); ret = (grib_darray**)grib_context_malloc_clear(c, sizeof(grib_darray*) * v->n);

View File

@ -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) void grib_viarray_delete_content(grib_context* c, grib_viarray* v)
{ {
int i; size_t i=0;
if (!v || !v->v) if (!v || !v->v)
return; 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** grib_viarray_get_array(grib_context* c, grib_viarray* v)
{ {
grib_iarray** ret; grib_iarray** ret;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (grib_iarray**)grib_context_malloc_clear(c, sizeof(grib_iarray*) * v->n); ret = (grib_iarray**)grib_context_malloc_clear(c, sizeof(grib_iarray*) * v->n);

View File

@ -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) void grib_vsarray_delete_content(grib_context* c, grib_vsarray* v)
{ {
int i; size_t i = 0;
if (!v || !v->v) if (!v || !v->v)
return; return;
if (!c) 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** grib_vsarray_get_array(grib_context* c, grib_vsarray* v)
{ {
grib_sarray** ret; grib_sarray** ret;
int i; size_t i = 0;
if (!v) if (!v)
return NULL; return NULL;
ret = (grib_sarray**)grib_context_malloc_clear(c, sizeof(grib_sarray*) * v->n); ret = (grib_sarray**)grib_context_malloc_clear(c, sizeof(grib_sarray*) * v->n);

View File

@ -185,7 +185,7 @@ static int process_file(const char* filename)
GRIB_CHECK(grib_get_size(h, "pl", &pl_len), 0); GRIB_CHECK(grib_get_size(h, "pl", &pl_len), 0);
assert(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); 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)); 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); 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", error(filename, msg_num, "Number of data points %d different from size of values array %d\n",
numberOfDataPoints, sizeOfValuesArray); numberOfDataPoints, sizeOfValuesArray);
} }