Fix cppcheck warnings

This commit is contained in:
Shahram Najm 2024-10-21 16:38:52 +00:00
parent 2479a8670c
commit ce006ec226
5 changed files with 6 additions and 6 deletions

View File

@ -256,7 +256,7 @@ int LambertAzimuthalEqualArea::init_sphere(grib_handle* h,
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}

View File

@ -166,7 +166,7 @@ int LambertConformal::init_sphere(const grib_handle* h,
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}
@ -291,7 +291,7 @@ int LambertConformal::init_oblate(const grib_handle* h,
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}

View File

@ -123,7 +123,7 @@ int Mercator::init_mercator(grib_handle* h,
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, nv * sizeof(double));
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}

View File

@ -186,7 +186,7 @@ int PolarStereographic::init(grib_handle* h, grib_arguments* args)
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv_ * sizeof(double));
return GRIB_OUT_OF_MEMORY;
}

View File

@ -227,7 +227,7 @@ int SpaceView::init(grib_handle* h, grib_arguments* args)
return GRIB_OUT_OF_MEMORY;
}
lons_ = (double*)grib_context_malloc(h->context, array_size);
if (!lats_) {
if (!lons_) {
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, array_size);
return GRIB_OUT_OF_MEMORY;
}