From c59a4badb0f46a08d9bdb9f6aff9531ddec58f71 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 13 Oct 2020 13:52:59 +0100 Subject: [PATCH] Fix logging format strings --- src/grib_accessor_class_bufr_elements_table.c | 2 +- src/grib_accessor_class_codetable.c | 4 ++-- src/grib_accessor_class_element.c | 4 ++-- src/grib_accessor_class_global_gaussian.c | 4 ++-- src/grib_fieldset.c | 22 +++++++++---------- src/grib_index.c | 4 ++-- src/grib_nearest_class_sh.c | 10 ++++----- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/grib_accessor_class_bufr_elements_table.c b/src/grib_accessor_class_bufr_elements_table.c index f908182dd..5ed43dd4d 100644 --- a/src/grib_accessor_class_bufr_elements_table.c +++ b/src/grib_accessor_class_bufr_elements_table.c @@ -407,7 +407,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i v = (bufr_descriptor*)grib_context_malloc_clear(c, sizeof(bufr_descriptor)); if (!v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_bufr_descriptor_new unable to allocate %d bytes\n", sizeof(bufr_descriptor)); + "grib_bufr_descriptor_new unable to allocate %ld bytes\n", sizeof(bufr_descriptor)); *err = GRIB_OUT_OF_MEMORY; return NULL; } diff --git a/src/grib_accessor_class_codetable.c b/src/grib_accessor_class_codetable.c index d991beb0e..4708a4334 100644 --- a/src/grib_accessor_class_codetable.c +++ b/src/grib_accessor_class_codetable.c @@ -461,7 +461,7 @@ static int grib_load_codetable(grib_context* c, const char* filename, } if (code < 0 || code >= size) { - grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: invalid code in %s: %d (table size=%d)", filename, code, size); + grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: invalid code in %s: %d (table size=%ld)", filename, code, size); continue; } @@ -502,7 +502,7 @@ static int grib_load_codetable(grib_context* c, const char* filename, Assert(*title); if (t->entries[code].abbreviation != NULL) { - grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: duplicate code in %s: %d (table size=%d)", filename, code, size); + grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: duplicate code in %s: %d (table size=%ld)", filename, code, size); continue; } diff --git a/src/grib_accessor_class_element.c b/src/grib_accessor_class_element.c index dd876705a..04c9f5ce1 100644 --- a/src/grib_accessor_class_element.c +++ b/src/grib_accessor_class_element.c @@ -165,7 +165,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 %d bytes", size * sizeof(long)); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %ld bytes", size * sizeof(long)); return GRIB_OUT_OF_MEMORY; } @@ -198,7 +198,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 %d bytes", size * sizeof(long)); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %ld bytes", size * sizeof(long)); return GRIB_OUT_OF_MEMORY; } diff --git a/src/grib_accessor_class_global_gaussian.c b/src/grib_accessor_class_global_gaussian.c index 8a64ab134..2ad735573 100644 --- a/src/grib_accessor_class_global_gaussian.c +++ b/src/grib_accessor_class_global_gaussian.c @@ -237,7 +237,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) lats = (double*)grib_context_malloc(c, sizeof(double) * N * 2); if (!lats) { grib_context_log(c, GRIB_LOG_ERROR, - "global_gaussian unpack_long: Memory allocation error: %d bytes", sizeof(double) * N * 2); + "global_gaussian unpack_long: Memory allocation error: %ld bytes", sizeof(double) * N * 2); return GRIB_OUT_OF_MEMORY; } if ((ret = grib_get_gaussian_latitudes(N, lats)) != GRIB_SUCCESS) @@ -323,7 +323,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) lats = (double*)grib_context_malloc(c, sizeof(double) * N * 2); if (!lats) { grib_context_log(c, GRIB_LOG_FATAL, - "global_gaussian pack_long: Memory allocation error: %d bytes", sizeof(double) * N * 2); + "global_gaussian pack_long: Memory allocation error: %ld bytes", sizeof(double) * N * 2); return GRIB_OUT_OF_MEMORY; } if ((ret = grib_get_gaussian_latitudes(N, lats)) != GRIB_SUCCESS) diff --git a/src/grib_fieldset.c b/src/grib_fieldset.c index 9243fc353..5bf49f205 100644 --- a/src/grib_fieldset.c +++ b/src/grib_fieldset.c @@ -78,7 +78,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) sizeof(long) * GRIB_START_ARRAY_SIZE); if (!set->columns[id].long_values) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_new_column : Cannot malloc %d bytes", + "grib_fieldset_new_column : Cannot malloc %ld bytes", sizeof(long) * GRIB_START_ARRAY_SIZE); err = GRIB_OUT_OF_MEMORY; return err; @@ -89,7 +89,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) sizeof(double) * GRIB_START_ARRAY_SIZE); if (!set->columns[id].double_values) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_new_column : Cannot malloc %d bytes", + "grib_fieldset_new_column : Cannot malloc %ld bytes", sizeof(double) * GRIB_START_ARRAY_SIZE); err = GRIB_OUT_OF_MEMORY; return err; @@ -100,7 +100,7 @@ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) sizeof(char*) * GRIB_START_ARRAY_SIZE); if (!set->columns[id].string_values) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_new_column : Cannot malloc %d bytes", + "grib_fieldset_new_column : Cannot malloc %ld bytes", sizeof(char*) * GRIB_START_ARRAY_SIZE); err = GRIB_OUT_OF_MEMORY; return err; @@ -178,7 +178,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) newsize * sizeof(long)); if (!newlongs) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_columns_resize : Cannot malloc %d bytes", newsize - set->columns[i].values_array_size); + "grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); return GRIB_OUT_OF_MEMORY; } else @@ -189,7 +189,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) newsize * sizeof(double)); if (!newdoubles) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_columns_resize : Cannot malloc %d bytes", newsize - set->columns[i].values_array_size); + "grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); return GRIB_OUT_OF_MEMORY; } else @@ -200,7 +200,7 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) newsize * sizeof(char*)); if (!newstrings) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_columns_resize : Cannot malloc %d bytes", newsize - set->columns[i].values_array_size); + "grib_fieldset_columns_resize : Cannot malloc %ld bytes", newsize - set->columns[i].values_array_size); return GRIB_OUT_OF_MEMORY; } else @@ -210,8 +210,8 @@ static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) newerrors = (int*)grib_context_realloc(c, set->columns[i].errors, newsize * sizeof(int)); if (!newerrors) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_columns_resize : Cannot malloc %d bytes", - set->columns[i].errors, newsize * sizeof(int)); + "grib_fieldset_columns_resize : Cannot malloc %ld bytes", + newsize * sizeof(int)); return GRIB_OUT_OF_MEMORY; } else @@ -333,7 +333,7 @@ static grib_fieldset* grib_fieldset_create_from_keys(grib_context* c, char** key set = (grib_fieldset*)grib_context_malloc_clear(c, msize); if (!set) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_create : Cannot malloc %d bytes", msize); + "grib_fieldset_create : Cannot malloc %ld bytes", msize); return NULL; } @@ -785,7 +785,7 @@ static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t si if (!a) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_create_int_array : Cannot malloc %d bytes", + "grib_fieldset_create_int_array : Cannot malloc %ld bytes", sizeof(grib_int_array)); return NULL; } @@ -793,7 +793,7 @@ static grib_int_array* grib_fieldset_create_int_array(grib_context* c, size_t si a->el = (int*)grib_context_malloc_clear(c, sizeof(int) * size); if (!a->el) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_fieldset_create_int_array : Cannot malloc %d bytes", + "grib_fieldset_create_int_array : Cannot malloc %ld bytes", sizeof(int) * size); return NULL; } diff --git a/src/grib_index.c b/src/grib_index.c index 8acb3080c..2d2d65514 100644 --- a/src/grib_index.c +++ b/src/grib_index.c @@ -249,7 +249,7 @@ static grib_index_key* grib_index_new_key(grib_context* c, grib_index_key* keys, next = (grib_index_key*)grib_context_malloc_clear(c, sizeof(grib_index_key)); if (!next) { grib_context_log(c, GRIB_LOG_ERROR, - "unable to allocate %d bytes", + "unable to allocate %ld bytes", sizeof(grib_index_key)); *err = GRIB_OUT_OF_MEMORY; return NULL; @@ -257,7 +257,7 @@ static grib_index_key* grib_index_new_key(grib_context* c, grib_index_key* keys, values = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); if (!values) { grib_context_log(c, GRIB_LOG_ERROR, - "unable to allocate %d bytes", + "unable to allocate %ld bytes", sizeof(grib_string_list)); *err = GRIB_OUT_OF_MEMORY; return NULL; diff --git a/src/grib_nearest_class_sh.c b/src/grib_nearest_class_sh.c index 0da390288..c753ed00c 100644 --- a/src/grib_nearest_class_sh.c +++ b/src/grib_nearest_class_sh.c @@ -117,7 +117,7 @@ static int find(grib_nearest* nearest, grib_handle* h, values = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); if (!values) { grib_context_log(h->context, GRIB_LOG_ERROR, - "nearest_sh: Error allocating %d bytes", + "nearest_sh: Error allocating %ld bytes", sizeof(double) * size); return GRIB_OUT_OF_MEMORY; } @@ -259,14 +259,14 @@ static int grib_invtrans(grib_context* context, int L, double latdeg, double lon c = (double*)grib_context_malloc_clear(context, sizeof(double) * Lp1); if (!c) { grib_context_log(context, GRIB_LOG_ERROR, - "nearest_sh: Error allocating %d bytes", sizeof(double) * Lp1); + "nearest_sh: Error allocating %ld bytes", sizeof(double) * Lp1); return GRIB_OUT_OF_MEMORY; } s = (double*)grib_context_malloc_clear(context, sizeof(double) * Lp1); if (!s) { grib_context_log(context, GRIB_LOG_ERROR, - "nearest_sh: Error allocating %d bytes", sizeof(double) * Lp1); + "nearest_sh: Error allocating %ld bytes", sizeof(double) * Lp1); return GRIB_OUT_OF_MEMORY; } @@ -275,13 +275,13 @@ static int grib_invtrans(grib_context* context, int L, double latdeg, double lon TR = (double*)grib_context_malloc_clear(context, sizeof(double) * Lp1); if (!TR) { grib_context_log(context, GRIB_LOG_ERROR, - "nearest_sh: Error allocating %d bytes", sizeof(double) * Lp1); + "nearest_sh: Error allocating %ld bytes", sizeof(double) * Lp1); return GRIB_OUT_OF_MEMORY; } TI = (double*)grib_context_malloc_clear(context, sizeof(double) * Lp1); if (!TI) { grib_context_log(context, GRIB_LOG_ERROR, - "nearest_sh: Error allocating %d bytes", sizeof(double) * Lp1); + "nearest_sh: Error allocating %ld bytes", sizeof(double) * Lp1); return GRIB_OUT_OF_MEMORY; }