mirror of https://github.com/ecmwf/eccodes.git
Compiler warnings: use '%zu' in the format string for size_t
This commit is contained in:
parent
c0f38fcf88
commit
c4e98b0342
|
@ -558,8 +558,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
}
|
||||
|
||||
/*
|
||||
printf("n_vals = %ld, bits8 = %ld\n", (long)n_vals, (long)bits8);
|
||||
printf("in %ld out => %ld\n", (long)bits8/8*n_vals,(long) buflen);
|
||||
printf("n_vals = %ld, bits8 = %ld\n", n_vals, bits8);
|
||||
printf("in %ld out => %zu\n", bits8/8*n_vals, buflen);
|
||||
*/
|
||||
buflen = strm.total_out;
|
||||
grib_buffer_replace(a, buf, buflen, 1, 1);
|
||||
|
|
|
@ -167,7 +167,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
|
||||
ar = (long*)grib_context_malloc_clear(c, size * sizeof(long));
|
||||
if (!ar) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %ld bytes", size * sizeof(long));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size * sizeof(long));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
|
||||
ar = (long*)grib_context_malloc_clear(c, size * sizeof(long));
|
||||
if (!ar) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %ld bytes", size * sizeof(long));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size * sizeof(long));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len)
|
|||
double dummyLon = 0, dummyVal = 0;
|
||||
int ret = 0;
|
||||
int i;
|
||||
long jScansPositively = 0; /*default: north to south*/
|
||||
long jScansPositively = 0; /* default: north to south */
|
||||
size_t size = *len;
|
||||
grib_context* c = a->context;
|
||||
grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), 0, &ret);
|
||||
|
@ -291,8 +291,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len)
|
|||
}
|
||||
v = (double*)grib_context_malloc_clear(c, size * sizeof(double));
|
||||
if (!v) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR,
|
||||
"Error allocating %ld bytes", (long)size * sizeof(double));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Error allocating %zu bytes", size * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
*val = v;
|
||||
|
@ -313,18 +312,18 @@ static int get_distinct(grib_accessor* a, double** val, long* len)
|
|||
|
||||
v1 = (double*)grib_context_malloc_clear(c, size * sizeof(double));
|
||||
if (!v1) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Error allocating %ld bytes", (long)size * sizeof(double));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Error allocating %zu bytes", size * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/*Construct a unique set of lats by filtering out duplicates*/
|
||||
/* Construct a unique set of lats by filtering out duplicates */
|
||||
prev = v[0];
|
||||
v1[0] = prev;
|
||||
count = 1;
|
||||
for (i = 1; i < *len; i++) {
|
||||
if (v[i] != prev) {
|
||||
prev = v[i];
|
||||
v1[count] = prev; /*Value different from previous so store it*/
|
||||
v1[count] = prev; /* Value different from previous so store it */
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,8 +270,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len)
|
|||
}
|
||||
v = (double*)grib_context_malloc_clear(c, size * sizeof(double));
|
||||
if (!v) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR,
|
||||
"Error allocating %ld bytes", (long)size * sizeof(double));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Error allocating %zu bytes", size * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
*val = v;
|
||||
|
@ -284,8 +283,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len)
|
|||
|
||||
v1 = (double*)grib_context_malloc_clear(c, size * sizeof(double));
|
||||
if (!v1) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR,
|
||||
"Error allocating %ld bytes", (long)size * sizeof(double));
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "Error allocating %zu bytes", size * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
if (size == 0)
|
||||
fprintf(self->dumper.out, "}\n");
|
||||
else
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%ld) }\n", (long)size);
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%zu) }\n", size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
if (size == 0)
|
||||
fprintf(self->dumper.out, "}\n");
|
||||
else
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%ld) }\n", (long)size);
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%zu) }\n", size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -585,7 +585,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
else
|
||||
fprintf(self->dumper.out, " ");
|
||||
|
||||
fprintf(self->dumper.out, "%s(%ld) = ", a->name, (long)size);
|
||||
fprintf(self->dumper.out, "%s(%zu) = ", a->name, size);
|
||||
aliases(d, a);
|
||||
fprintf(self->dumper.out, " {");
|
||||
|
||||
|
@ -593,7 +593,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
if (size == 0)
|
||||
fprintf(self->dumper.out, "}\n");
|
||||
else
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%ld) }\n", (long)size);
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%zu) }\n", size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,6 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
size_t size = a->length;
|
||||
unsigned char* buf;
|
||||
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)
|
||||
return;
|
||||
|
||||
|
@ -263,11 +262,10 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
buf = (unsigned char*)grib_context_malloc(d->context, size);
|
||||
|
||||
if (!buf) {
|
||||
fprintf(self->dumper.out, "/* %s: cannot malloc(%ld) */\n", a->name, (long)size);
|
||||
fprintf(self->dumper.out, "/* %s: cannot malloc(%zu) */\n", a->name, size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
err = grib_unpack_bytes(a, buf, &size);
|
||||
if (err) {
|
||||
grib_context_free(d->context, buf);
|
||||
|
@ -336,7 +334,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
|
||||
buf = (double*)grib_context_malloc(d->context, size * sizeof(double));
|
||||
if (!buf) {
|
||||
fprintf(self->dumper.out, "/* %s: cannot malloc(%ld) */\n", a->name, (long)size);
|
||||
fprintf(self->dumper.out, "/* %s: cannot malloc(%zu) */\n", a->name, size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -348,7 +346,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out, " size = %ld;\n", (long)size);
|
||||
fprintf(self->dumper.out, " size = %zu;\n", size);
|
||||
fprintf(self->dumper.out, " v%s = (%s*)calloc(size,sizeof(%s));\n", stype, stype, stype);
|
||||
fprintf(self->dumper.out, " if(!v%s) {\n", stype);
|
||||
fprintf(self->dumper.out, " fprintf(stderr,\"failed to allocate %%d bytes\\n\",size*sizeof(%s));\n", stype);
|
||||
|
|
|
@ -262,7 +262,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment)
|
|||
if (size == 0)
|
||||
fprintf(self->dumper.out, "}\n");
|
||||
else
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%ld) }\n", (long)size);
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%zu) }\n", size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -371,13 +371,13 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
|
|||
|
||||
buf = (double*)grib_context_malloc(d->context, size * sizeof(double));
|
||||
|
||||
fprintf(self->dumper.out, "%s (%ld) {", a->name, (long)size);
|
||||
fprintf(self->dumper.out, "%s (%zu) {", a->name, size);
|
||||
|
||||
if (!buf) {
|
||||
if (size == 0)
|
||||
fprintf(self->dumper.out, "}\n");
|
||||
else
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%ld) }\n", (long)size);
|
||||
fprintf(self->dumper.out, " *** ERR cannot malloc(%zu) }\n", size);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ static int iterate_reduced_gaussian_subarea_legacy(grib_iterator* iter, grib_han
|
|||
|
||||
if (h->context->debug) {
|
||||
const size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: Legacy sub-area num points=%ld\n", (long)np);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: Legacy sub-area num points=%zu\n", np);
|
||||
}
|
||||
|
||||
/*find starting latitude */
|
||||
|
@ -222,7 +222,7 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
|
|||
|
||||
if (h->context->debug) {
|
||||
const size_t np = count_subarea_points(h, get_reduced_row, pl, plsize, lon_first, lon_last);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%ld\n", (long)np);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%zu\n", np);
|
||||
}
|
||||
|
||||
/* Find starting latitude */
|
||||
|
@ -381,7 +381,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
iter->e = 0;
|
||||
if (h->context->debug) {
|
||||
const size_t np = count_global_points(pl, plsize);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: global num points=%ld\n", (long)np);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_iterator_class_gaussian_reduced: global num points=%zu\n", np);
|
||||
}
|
||||
|
||||
for (j = 0; j < plsize; j++) {
|
||||
|
|
|
@ -389,7 +389,7 @@ static void print_values(grib_context* c,
|
|||
for (i = 0; i < count; i++) {
|
||||
switch (keyval_pairs[i].type) {
|
||||
case GRIB_TYPE_LONG:
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: => %s = %ld;\n", keyval_pairs[i].name, (long)keyval_pairs[i].long_value);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: => %s = %ld;\n", keyval_pairs[i].name, keyval_pairs[i].long_value);
|
||||
break;
|
||||
case GRIB_TYPE_DOUBLE:
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: => %s = %.16e;\n", keyval_pairs[i].name, keyval_pairs[i].double_value);
|
||||
|
@ -629,8 +629,8 @@ static int check_geometry(grib_handle* handle, const grib_util_grid_spec2* spec,
|
|||
strcpy(msg, "Specified to be global (in spec)");
|
||||
sum = sum_of_pl_array(spec->pl, spec->pl_size);
|
||||
if (sum != data_values_count) {
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%ld!=%ld)\n",
|
||||
msg, (long)data_values_count, (long)sum);
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Invalid reduced gaussian grid: %s but data_values_count != sum_of_pl_array (%zu!=%zu)\n",
|
||||
msg, data_values_count, sum);
|
||||
return GRIB_WRONG_GRID;
|
||||
}
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
|
|||
setSecondOrder = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.packing_type (%ld)\n", (long)packing_spec->packing_type);
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.packing_type (%ld)\n", packing_spec->packing_type);
|
||||
*err = GRIB_INTERNAL_ERROR;
|
||||
goto cleanup;
|
||||
break;
|
||||
|
@ -1364,7 +1364,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.accuracy (%ld)\n", (long)packing_spec->accuracy);
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.accuracy (%ld)\n", packing_spec->accuracy);
|
||||
grib_handle_delete(h_sample);
|
||||
*err = GRIB_INTERNAL_ERROR;
|
||||
goto cleanup;
|
||||
|
@ -1423,8 +1423,8 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
|
|||
size_t sum = sum_of_pl_array(spec->pl, spec->pl_size);
|
||||
if (data_values_count != sum) {
|
||||
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid reduced gaussian grid: "
|
||||
"specified as global, data_values_count=%ld but sum of pl array=%ld\n",
|
||||
(long)data_values_count, (long)sum);
|
||||
"specified as global, data_values_count=%zu but sum of pl array=%zu\n",
|
||||
data_values_count, sum);
|
||||
*err = GRIB_WRONG_GRID;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
|
|||
|
||||
ferror = fopen("error.data", "w");
|
||||
lcount = 0;
|
||||
fprintf(ferror, "# data_values_count=%ld\n", (long)data_values_count);
|
||||
fprintf(ferror, "# data_values_count=%zu\n", data_values_count);
|
||||
fprintf(ferror, "set values={ ");
|
||||
for (ii = 0; ii < data_values_count - 1; ii++) {
|
||||
fprintf(ferror, "%g, ", data_values[ii]);
|
||||
|
|
|
@ -36,7 +36,7 @@ static void print_debug_info__set_double_array(grib_handle* h, const char* func,
|
|||
|
||||
if (length <= N)
|
||||
N = length;
|
||||
fprintf(stderr, "ECCODES DEBUG %s key=%s %lu values (", func, name, (unsigned long)length);
|
||||
fprintf(stderr, "ECCODES DEBUG %s key=%s %zu values (", func, name, length);
|
||||
for (i = 0; i < N; ++i) {
|
||||
if (i != 0) fprintf(stderr,", ");
|
||||
fprintf(stderr, "%.10g", val[i]);
|
||||
|
@ -93,7 +93,7 @@ int grib_set_long_internal(grib_handle* h, const char* name, long val)
|
|||
a = grib_find_accessor(h, name);
|
||||
|
||||
if (h->context->debug)
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long_internal %s=%ld\n", name, (long)val);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long_internal %s=%ld\n", name, val);
|
||||
|
||||
if (a) {
|
||||
ret = grib_pack_long(a, &val, &l);
|
||||
|
@ -121,9 +121,9 @@ int grib_set_long(grib_handle* h, const char* name, long val)
|
|||
if (a) {
|
||||
if (h->context->debug) {
|
||||
if (strcmp(name, a->name)!=0)
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld (a->name=%s)\n", name, (long)val, a->name);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld (a->name=%s)\n", name, val, a->name);
|
||||
else
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld\n", name, (long)val);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld\n", name, val);
|
||||
}
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)
|
||||
|
@ -491,7 +491,7 @@ int grib_set_string_array(grib_handle* h, const char* name, const char** val, si
|
|||
a = grib_find_accessor(h, name);
|
||||
|
||||
if (h->context->debug) {
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_string_array key=%s %ld values\n", name, (long)length);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_set_string_array key=%s %zu values\n", name, length);
|
||||
}
|
||||
|
||||
if (a) {
|
||||
|
@ -899,7 +899,7 @@ static int _grib_set_long_array(grib_handle* h, const char* name, const long* va
|
|||
size_t N = 5;
|
||||
if (length <= N)
|
||||
N = length;
|
||||
fprintf(stderr, "ECCODES DEBUG _grib_set_long_array key=%s %ld values (", name, (long)length);
|
||||
fprintf(stderr, "ECCODES DEBUG _grib_set_long_array key=%s %zu values (", name, length);
|
||||
for (i = 0; i < N; ++i)
|
||||
fprintf(stderr, " %ld,", val[i]);
|
||||
if (N >= length)
|
||||
|
|
Loading…
Reference in New Issue