Messages: Use ERROR rather than FATAL

This commit is contained in:
Shahram Najm 2023-02-20 14:11:19 +00:00
parent a19d5258a1
commit 067a3692ea
12 changed files with 34 additions and 35 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
* }
*/

View File

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

View File

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