From 8f31b291340eb154058d8d0528064a61577bbe55 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sun, 25 Feb 2024 15:54:02 +0000 Subject: [PATCH] Accessors: Type safety --- src/grib_accessor_class_gen.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/grib_accessor_class_gen.cc b/src/grib_accessor_class_gen.cc index 8b59b3b7a..c74479aeb 100644 --- a/src/grib_accessor_class_gen.cc +++ b/src/grib_accessor_class_gen.cc @@ -455,16 +455,14 @@ static int pack_long(grib_accessor* a, const long* v, size_t* len) { grib_context* c = a->context; if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - int i = 0, ret = 0; double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); if (!val) { - grib_context_log(c, GRIB_LOG_ERROR, - "Unable to allocate %zu bytes", *len * (sizeof(double))); + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double))); return GRIB_OUT_OF_MEMORY; } - for (i = 0; i < *len; i++) - val[i] = (long)v[i]; - ret = grib_pack_double(a, val, len); + for (size_t i = 0; i < *len; i++) + val[i] = v[i]; + int ret = grib_pack_double(a, val, len); grib_context_free(c, val); return ret; }