From 067a3692eab56c8bf33ccadd762223d523617a8d Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 20 Feb 2023 14:11:19 +0000 Subject: [PATCH] Messages: Use ERROR rather than FATAL --- src/grib_accessor_class_global_gaussian.cc | 4 +-- ...essor_class_second_order_bits_per_value.cc | 2 +- src/grib_dumper_class_bufr_decode_C.cc | 2 +- src/grib_dumper_class_bufr_encode_C.cc | 4 +-- src/grib_dumper_class_bufr_encode_filter.cc | 4 +-- src/grib_dumper_class_bufr_encode_fortran.cc | 4 +-- src/grib_dumper_class_bufr_encode_python.cc | 4 +-- src/grib_dumper_class_bufr_simple.cc | 2 +- src/grib_dumper_class_default.cc | 4 +-- src/grib_dumper_class_json.cc | 4 +-- src/grib_dumper_class_wmo.cc | 4 +-- src/grib_handle.cc | 31 +++++++++---------- 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/grib_accessor_class_global_gaussian.cc b/src/grib_accessor_class_global_gaussian.cc index 37bd565a1..a63d0015e 100644 --- a/src/grib_accessor_class_global_gaussian.cc +++ b/src/grib_accessor_class_global_gaussian.cc @@ -324,8 +324,8 @@ 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: %ld bytes", sizeof(double) * N * 2); + grib_context_log(c, GRIB_LOG_ERROR, + "global_gaussian pack_long: Memory allocation error: %zu 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_accessor_class_second_order_bits_per_value.cc b/src/grib_accessor_class_second_order_bits_per_value.cc index eb0a5811d..edc5be20f 100644 --- a/src/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/grib_accessor_class_second_order_bits_per_value.cc @@ -236,7 +236,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); if (!values) { - grib_context_log(a->context, GRIB_LOG_FATAL, "%s: Memory allocation error: %zu bytes", a->name, size); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Memory allocation error: %zu bytes", a->name, size); return GRIB_OUT_OF_MEMORY; } if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->values, values, &size)) != GRIB_SUCCESS) diff --git a/src/grib_dumper_class_bufr_decode_C.cc b/src/grib_dumper_class_bufr_decode_C.cc index f02070d8e..e658a29ba 100644 --- a/src/grib_dumper_class_bufr_decode_C.cc +++ b/src/grib_dumper_class_bufr_decode_C.cc @@ -489,7 +489,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm self->empty = 0; values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } diff --git a/src/grib_dumper_class_bufr_encode_C.cc b/src/grib_dumper_class_bufr_encode_C.cc index 5c915049f..385474470 100644 --- a/src/grib_dumper_class_bufr_encode_C.cc +++ b/src/grib_dumper_class_bufr_encode_C.cc @@ -621,7 +621,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm self->empty = 0; values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } @@ -682,7 +682,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(c, size); if (!value) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } diff --git a/src/grib_dumper_class_bufr_encode_filter.cc b/src/grib_dumper_class_bufr_encode_filter.cc index de3db03ca..308d5f7b4 100644 --- a/src/grib_dumper_class_bufr_encode_filter.cc +++ b/src/grib_dumper_class_bufr_encode_filter.cc @@ -557,7 +557,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } @@ -615,7 +615,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(c, size); if (!value) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } diff --git a/src/grib_dumper_class_bufr_encode_fortran.cc b/src/grib_dumper_class_bufr_encode_fortran.cc index 2c722a50c..5596718c6 100644 --- a/src/grib_dumper_class_bufr_encode_fortran.cc +++ b/src/grib_dumper_class_bufr_encode_fortran.cc @@ -672,7 +672,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } @@ -731,7 +731,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(c, size); if (!value) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } diff --git a/src/grib_dumper_class_bufr_encode_python.cc b/src/grib_dumper_class_bufr_encode_python.cc index f7344acdb..53c9a9352 100644 --- a/src/grib_dumper_class_bufr_encode_python.cc +++ b/src/grib_dumper_class_bufr_encode_python.cc @@ -614,7 +614,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } @@ -672,7 +672,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(c, size); if (!value) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } diff --git a/src/grib_dumper_class_bufr_simple.cc b/src/grib_dumper_class_bufr_simple.cc index 2759c20f5..19094f7c7 100644 --- a/src/grib_dumper_class_bufr_simple.cc +++ b/src/grib_dumper_class_bufr_simple.cc @@ -572,7 +572,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } diff --git a/src/grib_dumper_class_default.cc b/src/grib_dumper_class_default.cc index 53652da8c..0b64ce88a 100644 --- a/src/grib_dumper_class_default.cc +++ b/src/grib_dumper_class_default.cc @@ -350,7 +350,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } @@ -416,7 +416,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(c, size); if (!value) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } diff --git a/src/grib_dumper_class_json.cc b/src/grib_dumper_class_json.cc index b0f43bd10..7ccf07f7f 100644 --- a/src/grib_dumper_class_json.cc +++ b/src/grib_dumper_class_json.cc @@ -397,7 +397,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "Memory allocation error: %zu bytes", size); + grib_context_log(c, GRIB_LOG_ERROR, "Memory allocation error: %zu bytes", size); return; } @@ -458,7 +458,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) * if (size==0) return; * value=(char*)grib_context_malloc_clear(a->context,size); * if (!value) { - * grib_context_log(a->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size); + * grib_context_log(a->context,GRIB_LOG_ERROR,"unable to allocate %d bytes",(int)size); * return; * } */ diff --git a/src/grib_dumper_class_wmo.cc b/src/grib_dumper_class_wmo.cc index f896d04aa..86270e0b2 100644 --- a/src/grib_dumper_class_wmo.cc +++ b/src/grib_dumper_class_wmo.cc @@ -308,7 +308,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) ecc__grib_get_string_length(a, &size); value = (char*)grib_context_malloc_clear(a->context, size); if (!value) { - grib_context_log(a->context, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(a->context, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } err = grib_unpack_string(a, value, &size); @@ -630,7 +630,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm values = (char**)grib_context_malloc_clear(c, size * sizeof(char*)); if (!values) { - grib_context_log(c, GRIB_LOG_FATAL, "unable to allocate %d bytes", (int)size); + grib_context_log(c, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } diff --git a/src/grib_handle.cc b/src/grib_handle.cc index 2b152d846..931bdd6ea 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -9,9 +9,8 @@ */ /*************************************************************************** - * Jean Baptiste Filippi - 01.11.2005 - * Enrico Fucile - * * + * Jean Baptiste Filippi - 01.11.2005 * + * Enrico Fucile * ***************************************************************************/ #include "grib_api_internal.h" @@ -1375,25 +1374,25 @@ int codes_check_message_footer(const void* bytes, size_t length, ProductKind pro int grib_get_message_size(const grib_handle* ch, size_t* size) { long totalLength = 0; - int ret = 0; + int err = 0; grib_handle* h = (grib_handle*)ch; *size = h->buffer->ulength; - ret = grib_get_long(h, "totalLength", &totalLength); - if (!ret) + err = grib_get_long(h, "totalLength", &totalLength); + if (!err) *size = totalLength; - return ret; + return err; } int grib_get_message(const grib_handle* ch, const void** msg, size_t* size) { long totalLength = 0; - int ret = 0; + int err = 0; grib_handle* h = (grib_handle*)ch; *msg = h->buffer->data; *size = h->buffer->ulength; - ret = grib_get_long(h, "totalLength", &totalLength); - if (!ret) + err = grib_get_long(h, "totalLength", &totalLength); + if (!err) *size = totalLength; if (h->context->gts_header_on && h->gts_header) { @@ -1406,20 +1405,20 @@ int grib_get_message(const grib_handle* ch, const void** msg, size_t* size) int grib_get_message_headers(grib_handle* h, const void** msg, size_t* size) { - int ret = 0; + int err = 0; size_t endOfHeadersMarker; *msg = h->buffer->data; *size = h->buffer->ulength; - if ((ret = grib_get_offset(h, "endOfHeadersMarker", &endOfHeadersMarker)) != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_FATAL, - "grib_get_message_headers unable to get offset of endOfHeadersMarker"); - return ret; + if ((err = grib_get_offset(h, "endOfHeadersMarker", &endOfHeadersMarker)) != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "grib_get_message_headers: unable to get offset of endOfHeadersMarker"); + return err; } *size = endOfHeadersMarker; - return ret; + return err; } grib_handle* grib_handle_new(grib_context* c)