From 58e39c319739c6710e74c527446d22e62eae3487 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 12 Feb 2020 18:02:38 +0000 Subject: [PATCH] Clang static analyser: Dead assignment --- ...grib_accessor_class_data_g2bifourier_packing.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/grib_accessor_class_data_g2bifourier_packing.c b/src/grib_accessor_class_data_g2bifourier_packing.c index b5961e69d..f92f6a7b2 100644 --- a/src/grib_accessor_class_data_g2bifourier_packing.c +++ b/src/grib_accessor_class_data_g2bifourier_packing.c @@ -386,8 +386,9 @@ static double laplam(bif_trunc_t* bt, const double val[]) itab1 = (int*)malloc(sizeof(int) * kmax); itab2 = (int*)malloc(sizeof(int) * ((1 + bt->bif_i) * (1 + bt->bif_j))); - for (k = 0; k < kmax; k++) + for (k = 0; k < kmax; k++) { itab1[k] = 0; + } /* * Keep record of the possible values of i**2+j**2 outside the non-packed truncation @@ -405,12 +406,13 @@ static double laplam(bif_trunc_t* bt, const double val[]) } l = 0; - for (k = 0; k < kmax; k++) + for (k = 0; k < kmax; k++) { if (itab1[k]) { itab2[l] = k; itab1[k] = l; l++; } + } lmax = l; /* @@ -439,8 +441,13 @@ static double laplam(bif_trunc_t* bt, const double val[]) } else { int m, ll = itab1[i * i + j * j]; - for (m = 0; m < 4; m++, isp++) - znorm[ll] = MAX(znorm[ll], fabs(val[isp])); + for (m = 0; m < 4; m++, isp++) { + DebugAssertAccess(znorm, (long)ll, (long)lmax); + DebugAssertAccess(val, (long)isp, bt->n_vals_bif); + if (ll < lmax && isp < bt->n_vals_bif) { + znorm[ll] = MAX(znorm[ll], fabs(val[isp])); + } + } } }