mirror of https://github.com/ecmwf/eccodes.git
Examples: use '%zu' in the format string for size_t
This commit is contained in:
parent
55e9287fab
commit
0908028394
|
@ -321,8 +321,9 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len)
|
|||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
|
||||
int ret = 0, i, idx;
|
||||
char* s = NULL;
|
||||
int ret = GRIB_SUCCESS, idx = 0;
|
||||
size_t i = 0;
|
||||
char* s = NULL;
|
||||
grib_context* c = a->context;
|
||||
|
||||
if (self->compressedData) {
|
||||
|
@ -420,7 +421,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
|
||||
int ret = 0, idx;
|
||||
int ret = GRIB_SUCCESS, idx = 0;
|
||||
char* s = NULL;
|
||||
grib_context* c = a->context;
|
||||
|
||||
|
@ -442,8 +443,8 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = 0, i;
|
||||
long count = 0;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0, i = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
|
||||
|
@ -471,8 +472,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = 0, i;
|
||||
long count = 0;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0, i = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
|
||||
|
@ -500,9 +501,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
||||
{
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = 0, i;
|
||||
long count = 1;
|
||||
grib_context* c = a->context;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 1, i = 0;
|
||||
grib_context* c = a->context;
|
||||
|
||||
if (self->compressedData) {
|
||||
count = *len;
|
||||
|
|
|
@ -84,7 +84,7 @@ static void* default_long_lasting_malloc(const grib_context* c, size_t size)
|
|||
void* ret;
|
||||
ret = malloc(size);
|
||||
if (!ret) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_long_lasting_malloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_long_lasting_malloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return ret;
|
||||
|
@ -100,7 +100,7 @@ static void* default_buffer_malloc(const grib_context* c, size_t size)
|
|||
void* ret;
|
||||
ret = malloc(size);
|
||||
if (!ret) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_buffer_malloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_buffer_malloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return ret;
|
||||
|
@ -111,7 +111,7 @@ static void* default_buffer_realloc(const grib_context* c, void* p, size_t size)
|
|||
void* ret;
|
||||
ret = realloc(p, size);
|
||||
if (!ret) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_buffer_realloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_buffer_realloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return ret;
|
||||
|
@ -127,7 +127,7 @@ static void* default_malloc(const grib_context* c, size_t size)
|
|||
void* ret;
|
||||
ret = malloc(size);
|
||||
if (!ret) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_malloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_malloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return ret;
|
||||
|
@ -138,7 +138,7 @@ static void* default_realloc(const grib_context* c, void* p, size_t size)
|
|||
void* ret;
|
||||
ret = realloc(p, size);
|
||||
if (!ret) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_realloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "default_realloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return ret;
|
||||
|
@ -905,7 +905,7 @@ void* grib_context_malloc_persistent(const grib_context* c, size_t size)
|
|||
void* p = c->alloc_persistent_mem(c, size);
|
||||
if (!p) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL,
|
||||
"grib_context_malloc_persistent: error allocating %lu bytes", (unsigned long)size);
|
||||
"grib_context_malloc_persistent: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return p;
|
||||
|
@ -937,7 +937,7 @@ void* grib_context_malloc(const grib_context* c, size_t size)
|
|||
else
|
||||
p = c->alloc_mem(c, size);
|
||||
if (!p) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_malloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_malloc: error allocating %zu bytes", size);
|
||||
Assert(0);
|
||||
}
|
||||
return p;
|
||||
|
@ -950,7 +950,7 @@ void* grib_context_realloc(const grib_context* c, void* p, size_t size)
|
|||
c = grib_context_get_default();
|
||||
q = c->realloc_mem(c, p, size);
|
||||
if (!q) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_realloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_realloc: error allocating %zu bytes", size);
|
||||
return NULL;
|
||||
}
|
||||
return q;
|
||||
|
@ -985,7 +985,7 @@ void* grib_context_buffer_malloc(const grib_context* c, size_t size)
|
|||
else
|
||||
p = c->alloc_buffer_mem(c, size);
|
||||
if (!p) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_buffer_malloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_buffer_malloc: error allocating %zu bytes", size);
|
||||
return NULL;
|
||||
}
|
||||
return p;
|
||||
|
@ -1003,7 +1003,7 @@ void* grib_context_buffer_realloc(const grib_context* c, void* p, size_t size)
|
|||
{
|
||||
void* q = c->realloc_buffer_mem(c, p, size);
|
||||
if (!q) {
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_buffer_realloc: error allocating %lu bytes", (unsigned long)size);
|
||||
grib_context_log(c, GRIB_LOG_FATAL, "grib_context_buffer_realloc: error allocating %zu bytes", size);
|
||||
return NULL;
|
||||
}
|
||||
return q;
|
||||
|
|
|
@ -15,9 +15,9 @@ void grib_darray_print(const char* title, const grib_darray* darray)
|
|||
{
|
||||
size_t i;
|
||||
Assert(darray);
|
||||
printf("%s: darray.n=%lu \t", title, (unsigned long)darray->n);
|
||||
printf("%s: darray.n=%zu \t", title, darray->n);
|
||||
for (i = 0; i < darray->n; i++) {
|
||||
printf("darray[%lu]=%g\t", (unsigned long)i, darray->v[i]);
|
||||
printf("darray[%zu]=%g\t", i, darray->v[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
*/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* Enrico Fucile
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
@ -21,9 +19,9 @@ void grib_iarray_print(const char* title, const grib_iarray* iarray)
|
|||
{
|
||||
size_t i;
|
||||
Assert(iarray);
|
||||
printf("%s: iarray.n=%lu \t", title, (unsigned long)iarray->n);
|
||||
printf("%s: iarray.n=%zu \t", title, iarray->n);
|
||||
for (i = 0; i < iarray->n; i++) {
|
||||
printf("iarray[%lu]=%ld\t", (unsigned long)i, iarray->v[i]);
|
||||
printf("iarray[%zu]=%ld\t", i, iarray->v[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ static void print_values(grib_context* c,
|
|||
size_t i = 0;
|
||||
int isConstant = 1;
|
||||
double v = 0, minVal = DBL_MAX, maxVal = -DBL_MAX;
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: grib_set_values, setting %lu key/value pairs\n", (unsigned long)count);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: grib_set_values, setting %zu key/value pairs\n", count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
switch (keyval_pairs[i].type) {
|
||||
|
@ -400,7 +400,7 @@ static void print_values(grib_context* c,
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: data_values_count=%lu;\n", (unsigned long)data_values_count);
|
||||
fprintf(stderr, "ECCODES DEBUG grib_util: data_values_count=%zu;\n", data_values_count);
|
||||
for (i = 0; i < data_values_count; i++) {
|
||||
if (i == 0)
|
||||
v = data_values[i];
|
||||
|
|
|
@ -22,9 +22,9 @@ void grib_vdarray_print(const char* title, const grib_vdarray* vdarray)
|
|||
size_t i = 0;
|
||||
char text[100] = {0,};
|
||||
Assert(vdarray);
|
||||
printf("%s: vdarray.n=%lu\n", title, (unsigned long)vdarray->n);
|
||||
printf("%s: vdarray.n=%zu\n", title, vdarray->n);
|
||||
for (i = 0; i < vdarray->n; i++) {
|
||||
snprintf(text, sizeof(text), " vdarray->v[%lu]", (unsigned long)i);
|
||||
snprintf(text, sizeof(text), " vdarray->v[%zu]", i);
|
||||
grib_darray_print(text, vdarray->v[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
|
|
@ -23,9 +23,9 @@ void grib_viarray_print(const char* title, const grib_viarray* viarray)
|
|||
char text[100] = {0,};
|
||||
const size_t textLen = sizeof(text);
|
||||
Assert(viarray);
|
||||
printf("%s: viarray.n=%lu\n", title, (unsigned long)viarray->n);
|
||||
printf("%s: viarray.n=%zu\n", title, viarray->n);
|
||||
for (i = 0; i < viarray->n; i++) {
|
||||
snprintf(text, textLen, " viarray->v[%lu]", (unsigned long)i);
|
||||
snprintf(text, textLen, " viarray->v[%zu]", i);
|
||||
grib_iarray_print(text, viarray->v[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
|
|
@ -559,8 +559,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
|
|||
|
||||
while ((global_handle = codes_bufr_handle_new_from_file(c, options->infile_extra->file, &err))) {
|
||||
morein1++;
|
||||
if (global_handle)
|
||||
grib_handle_delete(global_handle);
|
||||
grib_handle_delete(global_handle);
|
||||
}
|
||||
|
||||
error += morein1 + morein2;
|
||||
|
@ -889,7 +888,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 != len2) {
|
||||
printInfo(handle1);
|
||||
printf("Different size for \"%s\" [%ld] [%ld]\n", name, (long)len1, (long)len2);
|
||||
printf("Different size for \"%s\" [%zu] [%zu]\n", name, len1, len2);
|
||||
err1 = GRIB_INTERNAL_ERROR;
|
||||
save_error(c, name);
|
||||
}
|
||||
|
@ -907,7 +906,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
if (len1 == 1)
|
||||
printf("string [%s]: [%s] != [%s]\n", name, *svals1, *svals2);
|
||||
else
|
||||
printf("string [%s] %d out of %ld different\n", name, countdiff, (long)len1);
|
||||
printf("string [%s] %d out of %zu different\n", name, countdiff, len1);
|
||||
}
|
||||
}
|
||||
for (ii = 0; ii < len1; ++ii) grib_context_free(c, svals1[ii]);
|
||||
|
@ -945,7 +944,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 != len2) {
|
||||
printInfo(handle1);
|
||||
printf("Different size for \"%s\" [%ld] [%ld]\n", name, (long)len1, (long)len2);
|
||||
printf("Different size for \"%s\" [%zu] [%zu]\n", name, len1, len2);
|
||||
err1 = GRIB_INTERNAL_ERROR;
|
||||
save_error(c, name);
|
||||
}
|
||||
|
@ -963,7 +962,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
if (len1 == 1)
|
||||
printf("long [%s]: [%ld] != [%ld]\n", name, *lval1, *lval2);
|
||||
else
|
||||
printf("long [%s] %d out of %ld different\n", name, countdiff, (long)len1);
|
||||
printf("long [%s] %d out of %zu different\n", name, countdiff, len1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1029,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 != len2) {
|
||||
printInfo(handle1);
|
||||
printf("Different size for \"%s\" [%ld] [%ld]\n", name, (long)len1, (long)len2);
|
||||
printf("Different size for \"%s\" [%zu] [%zu]\n", name, len1, len2);
|
||||
save_error(c, name);
|
||||
}
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 == len2) {
|
||||
|
@ -1074,7 +1073,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
|
|||
printInfo(handle1);
|
||||
save_error(c, name);
|
||||
if (len1 > 1) {
|
||||
printf("double [%s]: %d out of %ld different\n", name, countdiff, (long)len1);
|
||||
printf("double [%s]: %d out of %zu different\n", name, countdiff, len1);
|
||||
if (dval1[imaxdiff] != GRIB_MISSING_DOUBLE && dval2[imaxdiff] != GRIB_MISSING_DOUBLE) {
|
||||
if (compareAbsolute)
|
||||
printf(" max");
|
||||
|
|
|
@ -84,7 +84,7 @@ static int split_file(FILE* in, const char* filename, const int nchunks, unsigne
|
|||
msg_size += size;
|
||||
if (read_size > chunk_size && msg_size < insize) {
|
||||
if (verbose)
|
||||
printf("Wrote output file %s (%lu msgs)\n", ofilename, (unsigned long)num_msg);
|
||||
printf("Wrote output file %s (%zu msgs)\n", ofilename, num_msg);
|
||||
fclose(out);
|
||||
i++;
|
||||
/* Start writing to the next file */
|
||||
|
@ -103,7 +103,7 @@ static int split_file(FILE* in, const char* filename, const int nchunks, unsigne
|
|||
}
|
||||
}
|
||||
if (verbose)
|
||||
printf("Wrote output file %s (%lu msgs)\n", ofilename, (unsigned long)num_msg - 1);
|
||||
printf("Wrote output file %s (%zu msgs)\n", ofilename, num_msg - 1);
|
||||
fclose(out);
|
||||
free(ofilename);
|
||||
|
||||
|
|
|
@ -840,7 +840,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 != len2) {
|
||||
printInfo(h1);
|
||||
printf("Different size for \"%s\" [%ld] [%ld]\n", name, (long)len1, (long)len2);
|
||||
printf("Different size for \"%s\" [%zu] [%zu]\n", name, len1, len2);
|
||||
save_error(c, name);
|
||||
}
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 == len2) {
|
||||
|
@ -865,7 +865,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
printf("\n");
|
||||
}
|
||||
else {
|
||||
printf("long [%s] %d out of %ld different\n", name, countdiff, (long)len1);
|
||||
printf("long [%s] %d out of %zu different\n", name, countdiff, len1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 != len2) {
|
||||
printInfo(h1);
|
||||
printf("Different size for \"%s\" [%ld] [%ld]\n", name, (long)len1, (long)len2);
|
||||
printf("Different size for \"%s\" [%zu] [%zu]\n", name, len1, len2);
|
||||
save_error(c, name);
|
||||
}
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 == len2) {
|
||||
|
@ -1012,7 +1012,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
printInfo(h1);
|
||||
save_error(c, name);
|
||||
if (len1 > 1) {
|
||||
printf("double [%s]: %d out of %ld different\n", name, countdiff, (long)len1);
|
||||
printf("double [%s]: %d out of %zu different\n", name, countdiff, len1);
|
||||
if (compareAbsolute)
|
||||
printf(" max");
|
||||
printf(" absolute diff. = %.16e,", fabs(dval1[imaxdiff] - dval2[imaxdiff]));
|
||||
|
|
|
@ -332,8 +332,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
|
||||
if (!global_handle || err != GRIB_SUCCESS) {
|
||||
morein1++;
|
||||
if (global_handle)
|
||||
grib_handle_delete(global_handle);
|
||||
grib_handle_delete(global_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue