Accessors: Return correct array length

This commit is contained in:
shahramn 2024-03-09 18:50:28 +00:00
parent 6f710bdcbf
commit 9cda220036
4 changed files with 8 additions and 8 deletions

View File

@ -908,9 +908,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
}
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values",
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values",
*len, a->name, rlen);
*len = 0;
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -167,8 +167,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen);
*len = 0;
"Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen);
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -163,7 +163,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
*len = rlen;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -208,7 +208,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
const double dval = *val;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
@ -233,7 +233,7 @@ static int pack_float(grib_accessor* a, const float* val, size_t* len)
const double fval = *val;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}
@ -252,7 +252,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
grib_accessor_variable* self = (grib_accessor_variable*)a;
if (*len != 1) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains 1 value", a->name);
*len = 1;
return GRIB_ARRAY_TOO_SMALL;
}