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_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;

View File

@ -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)

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)
{
grib_context* c;
int i;
grib_context* c = NULL;
size_t i = 0;
bufr_descriptor** vv = NULL;
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* 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;

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** 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];
}

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)
{
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);

View File

@ -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);

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)
{
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);

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)
{
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);

View File

@ -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);
}