diff --git a/src/bufr_util.c b/src/bufr_util.c index d22b809f4..21842a3fe 100644 --- a/src/bufr_util.c +++ b/src/bufr_util.c @@ -590,7 +590,7 @@ static int count_bufr_messages(grib_context* c, FILE* f, int* n, int strict_mode err = GRIB_INTERNAL_ERROR; } } - + (void)done; rewind(f); if (err == GRIB_END_OF_FILE) err = GRIB_SUCCESS; diff --git a/src/grib_accessor_class_data_g1second_order_row_by_row_packing.c b/src/grib_accessor_class_data_g1second_order_row_by_row_packing.c index ffabc88b1..c6c76fc5a 100644 --- a/src/grib_accessor_class_data_g1second_order_row_by_row_packing.c +++ b/src/grib_accessor_class_data_g1second_order_row_by_row_packing.c @@ -249,7 +249,7 @@ static int value_count(grib_accessor* a, long* count) long *bitmap, *pbitmap; size_t numberOfPoints = 0; - if (plSize) { + if (plSize && pl) { for (i = 0; i < numberOfRows; i++) numberOfPoints += pl[i]; grib_context_free(c, pl); @@ -342,7 +342,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) long *bitmap, *pbitmap; size_t numberOfPoints = Ni * Nj; - if (plSize) { + if (plSize && pl) { numberOfPoints = 0; for (i = 0; i < numberOfRows; i++) numberOfPoints += pl[i]; @@ -350,7 +350,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) bitmap = (long*)grib_context_malloc_clear(a->context, sizeof(long) * numberOfPoints); pbitmap = bitmap; grib_get_long_array(gh, self->bitmap, bitmap, &numberOfPoints); - if (plSize) { + if (plSize && pl) { for (i = 0; i < numberOfRows; i++) { for (j = 0; j < pl[i]; j++) { numbersPerRow[i] += *(bitmap++); @@ -369,7 +369,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) grib_context_free(a->context, pbitmap); } else { - if (plSize) { + if (plSize && pl) { for (i = 0; i < numberOfRows; i++) numbersPerRow[i] = pl[i]; } diff --git a/src/grib_accessor_class_gen.c b/src/grib_accessor_class_gen.c index e6d51763a..797cf5145 100644 --- a/src/grib_accessor_class_gen.c +++ b/src/grib_accessor_class_gen.c @@ -593,8 +593,9 @@ static int is_missing(grib_accessor* a) if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { if (a->vvalue == NULL) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%X)", a->name, a->flags); + Assert(!"grib_accessor_class_gen::is_missing(): a->vvalue == NULL"); + return 0; } - Assert(a->vvalue != NULL); return a->vvalue->missing; } Assert(a->length >= 0); diff --git a/src/grib_accessor_class_md5.c b/src/grib_accessor_class_md5.c index 6c646b563..bb6603820 100644 --- a/src/grib_accessor_class_md5.c +++ b/src/grib_accessor_class_md5.c @@ -146,7 +146,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) self->offset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); self->length = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, n++); - self->blacklist = 0; + self->blacklist = NULL; while ((b = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++)) != NULL) { if (!self->blacklist) { self->blacklist = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list)); @@ -154,9 +154,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) current = self->blacklist; } else { - current->next = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list)); - current->next->value = grib_context_strdup(context, b); - current = current->next; + Assert(current); + if (current) { + current->next = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list)); + current->next->value = grib_context_strdup(context, b); + current = current->next; + } } } a->length = 0; diff --git a/src/grib_expression.c b/src/grib_expression.c index 60580d942..b2fd9fdab 100644 --- a/src/grib_expression.c +++ b/src/grib_expression.c @@ -67,7 +67,7 @@ const char* grib_expression_get_name(grib_expression* g) return c->get_name(g); c = c->super ? *(c->super) : NULL; } - printf("No expression_get_name() in %s\n", g->cclass->name); + if (g->cclass) printf("No expression_get_name() in %s\n", g->cclass->name); Assert(1 == 0); return 0; } diff --git a/src/grib_ieeefloat.c b/src/grib_ieeefloat.c index c27aa4830..5e8851895 100644 --- a/src/grib_ieeefloat.c +++ b/src/grib_ieeefloat.c @@ -130,7 +130,7 @@ unsigned long grib_ieee_to_long(double x) unsigned long s = 0; unsigned long mmax = 0xffffff; unsigned long mmin = 0x800000; - unsigned long m = mmax; + unsigned long m = 0; unsigned long e = 0; double rmmax = mmax + 0.5; diff --git a/tools/grib_to_netcdf.c b/tools/grib_to_netcdf.c index 67e8de3e4..379fc24f1 100644 --- a/tools/grib_to_netcdf.c +++ b/tools/grib_to_netcdf.c @@ -2549,13 +2549,14 @@ static void scale_bitmap(double* vals, long n, void* data, dataset_t* subset) int i = 0; nc_type nctype = subset->att.nctype; - /* - if(!subset->bitmap) - { - grib_context_log(ctx,GRIB_LOG_DEBUG,"No scale of bitmap required"); - return; - } - */ + /* if(!subset->bitmap) { + grib_context_log(ctx,GRIB_LOG_DEBUG,"No scale of bitmap required"); + return; + } */ + if (n > 0 && !vals) { + Assert(!"scale_bitmap: n > 0 but vals == NULL"); + return; + } switch (nctype) { case NC_BYTE: {