From 9a621fc454485380ce507881e1c2498d98056f9b Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 20 Dec 2024 12:58:07 +0000 Subject: [PATCH] Rename macro: Assert -> ECCODES_ASSERT --- fortran/grib_fortran.cc | 34 +- src/accessor/grib_accessor_class_ascii.cc | 2 +- src/accessor/grib_accessor_class_bitmap.cc | 8 +- src/accessor/grib_accessor_class_bits.cc | 2 +- src/accessor/grib_accessor_class_blob.cc | 2 +- src/accessor/grib_accessor_class_budgdate.cc | 2 +- .../grib_accessor_class_bufr_data_array.cc | 22 +- .../grib_accessor_class_bufr_data_element.cc | 4 +- ...grib_accessor_class_bufr_elements_table.cc | 4 +- src/accessor/grib_accessor_class_bytes.cc | 4 +- .../grib_accessor_class_cf_var_name.cc | 4 +- ...ccessor_class_change_scanning_direction.cc | 4 +- ...b_accessor_class_check_internal_version.cc | 2 +- .../grib_accessor_class_closest_date.cc | 14 +- src/accessor/grib_accessor_class_codeflag.cc | 2 +- src/accessor/grib_accessor_class_codetable.cc | 22 +- src/accessor/grib_accessor_class_concept.cc | 2 +- .../grib_accessor_class_data_apply_bitmap.cc | 2 +- ...cessor_class_data_apply_boustrophedonic.cc | 4 +- ...class_data_apply_boustrophedonic_bitmap.cc | 8 +- .../grib_accessor_class_data_ccsds_packing.cc | 2 +- ...rib_accessor_class_data_complex_packing.cc | 4 +- ...b_accessor_class_data_g1complex_packing.cc | 2 +- ...g1second_order_general_extended_packing.cc | 6 +- ..._accessor_class_data_g1secondary_bitmap.cc | 2 +- ...ib_accessor_class_data_g1simple_packing.cc | 2 +- ...ib_accessor_class_data_g22order_packing.cc | 4 +- ...accessor_class_data_g2bifourier_packing.cc | 4 +- ..._accessor_class_data_g2secondary_bitmap.cc | 2 +- ...ata_g2simple_packing_with_preprocessing.cc | 4 +- ...ib_accessor_class_data_jpeg2000_packing.cc | 8 +- .../grib_accessor_class_data_png_packing.cc | 16 +- .../grib_accessor_class_data_raw_packing.cc | 2 +- ...ib_accessor_class_data_secondary_bitmap.cc | 4 +- .../grib_accessor_class_data_sh_packed.cc | 10 +- .../grib_accessor_class_data_sh_unpacked.cc | 14 +- ...grib_accessor_class_data_simple_packing.cc | 8 +- src/accessor/grib_accessor_class_element.cc | 8 +- ...rib_accessor_class_expanded_descriptors.cc | 12 +- .../grib_accessor_class_g1forecastmonth.cc | 2 +- .../grib_accessor_class_g1step_range.cc | 2 +- .../grib_accessor_class_g2_aerosol.cc | 2 +- .../grib_accessor_class_g2_chemical.cc | 6 +- .../grib_accessor_class_g2end_step.cc | 10 +- src/accessor/grib_accessor_class_g2grid.cc | 2 +- src/accessor/grib_accessor_class_gen.cc | 6 +- .../grib_accessor_class_global_gaussian.cc | 6 +- .../grib_accessor_class_hash_array.cc | 2 +- src/accessor/grib_accessor_class_ibmfloat.cc | 4 +- src/accessor/grib_accessor_class_ieeefloat.cc | 4 +- .../grib_accessor_class_ksec1expver.cc | 4 +- .../grib_accessor_class_latlon_increment.cc | 2 +- .../grib_accessor_class_local_definition.cc | 2 +- .../grib_accessor_class_long_vector.cc | 2 +- src/accessor/grib_accessor_class_lookup.cc | 2 +- src/accessor/grib_accessor_class_md5.cc | 2 +- src/accessor/grib_accessor_class_message.cc | 2 +- ...ccessor_class_number_of_points_gaussian.cc | 4 +- ...class_number_of_values_data_raw_packing.cc | 2 +- ...grib_accessor_class_octahedral_gaussian.cc | 2 +- src/accessor/grib_accessor_class_padding.cc | 2 +- .../grib_accessor_class_proj_string.cc | 4 +- src/accessor/grib_accessor_class_raw.cc | 4 +- ...ib_accessor_class_reference_value_error.cc | 2 +- src/accessor/grib_accessor_class_section.cc | 6 +- .../grib_accessor_class_section_length.cc | 2 +- .../grib_accessor_class_section_padding.cc | 2 +- .../grib_accessor_class_section_pointer.cc | 2 +- src/accessor/grib_accessor_class_signed.cc | 10 +- ...rib_accessor_class_simple_packing_error.cc | 2 +- .../grib_accessor_class_smart_table.cc | 2 +- src/accessor/grib_accessor_class_sprintf.cc | 2 +- ...b_accessor_class_unexpanded_descriptors.cc | 2 +- src/accessor/grib_accessor_class_unsigned.cc | 6 +- src/accessor/grib_accessor_class_values.cc | 6 +- src/accessor/grib_accessor_class_vector.cc | 4 +- src/action.cc | 10 +- src/action_class_concept.cc | 6 +- src/action_class_gen.cc | 2 +- src/action_class_hash_array.cc | 4 +- src/action_class_section.cc | 18 +- src/action_class_switch.cc | 2 +- src/action_class_write.cc | 2 +- src/bufr_util.cc | 10 +- src/codes_util.cc | 10 +- src/dumper/grib_dumper_class_bufr_decode_C.cc | 2 +- src/dumper/grib_dumper_class_bufr_encode_C.cc | 10 +- .../grib_dumper_class_bufr_encode_filter.cc | 10 +- .../grib_dumper_class_bufr_encode_fortran.cc | 8 +- .../grib_dumper_class_bufr_encode_python.cc | 8 +- src/dumper/grib_dumper_class_bufr_simple.cc | 12 +- src/dumper/grib_dumper_class_default.cc | 4 +- src/dumper/grib_dumper_class_grib_encode_C.cc | 2 +- src/dumper/grib_dumper_class_json.cc | 6 +- src/dumper/grib_dumper_class_serialize.cc | 2 +- src/dumper/grib_dumper_class_wmo.cc | 2 +- .../grib_expression_class_accessor.cc | 4 +- .../grib_expression_class_is_in_dict.cc | 2 +- .../grib_expression_class_is_in_list.cc | 2 +- .../grib_expression_class_is_integer.cc | 2 +- .../grib_expression_class_length.cc | 4 +- src/functions.cc | 8 +- src/geo/GeoIterator.cc | 8 +- src/geo/grib_gaussian_reduced.cc | 12 +- src/geo/iterator/grib_iterator.cc | 4 +- .../iterator/grib_iterator_class_gaussian.cc | 2 +- .../grib_iterator_class_gaussian_reduced.cc | 6 +- .../iterator/grib_iterator_class_healpix.cc | 10 +- ...ator_class_lambert_azimuthal_equal_area.cc | 2 +- .../iterator/grib_iterator_class_latlon.cc | 2 +- src/geo/nearest/grib_nearest.cc | 12 +- src/geo/nearest/grib_nearest_class_regular.cc | 2 +- src/grib_accessor_class.cc | 8 +- src/grib_accessor_classes_hash.cc | 6 +- src/grib_api_internal.h | 4 +- src/grib_bits.cc | 10 +- src/grib_bits_any_endian.cc | 18 +- src/grib_bits_any_endian_omp.cc | 2 +- src/grib_bits_any_endian_simple.cc | 2 +- src/grib_bits_fast_big_endian.cc | 2 +- src/grib_bits_fast_big_endian_vector.cc | 10 +- src/grib_bits_ibmpow.cc | 10 +- src/grib_bufr_descriptor.cc | 6 +- src/grib_context.cc | 12 +- src/grib_darray.cc | 2 +- src/grib_dependency.cc | 4 +- src/grib_dumper_factory.cc | 2 +- src/grib_handle.cc | 12 +- src/grib_hash_keys.cc | 4 +- src/grib_iarray.cc | 4 +- src/grib_ibmfloat.cc | 6 +- src/grib_ieeefloat.cc | 8 +- src/grib_index.cc | 16 +- src/grib_io.cc | 14 +- src/grib_itrie.cc | 6 +- src/grib_itrie_keys.cc | 4 +- src/grib_jasper_encoding.cc | 6 +- src/grib_keys_iterator.cc | 2 +- src/grib_memory.cc | 2 +- src/grib_openjpeg_encoding.cc | 20 +- src/grib_parse_utils.cc | 12 +- src/grib_sarray.cc | 2 +- src/grib_scaling.cc | 10 +- src/grib_templates.cc | 2 +- src/grib_trie.cc | 4 +- src/grib_util.cc | 42 +- src/grib_value.cc | 12 +- src/grib_vdarray.cc | 2 +- src/grib_viarray.cc | 2 +- src/md5.cc | 2 +- src/string_util.cc | 6 +- tests/bits.cc | 2 +- tests/bufr_check_descriptors.cc | 6 +- tests/bufr_encode_pthreads.cc | 12 +- tests/codes_codetable.cc | 46 +-- tests/codes_compare_keys.cc | 8 +- tests/codes_new_from_samples.cc | 6 +- tests/codes_set_samples_path.cc | 8 +- tests/grib_bpv_limit.cc | 6 +- tests/grib_check_param_concepts.cc | 10 +- tests/grib_ecc-1431.cc | 12 +- tests/grib_ecc-1433.cc | 2 +- tests/grib_ecc-1467.cc | 10 +- tests/grib_ecc-386.cc | 4 +- tests/grib_encode_pthreads.cc | 6 +- tests/grib_encode_pthreads2.cc | 6 +- tests/grib_geo_iter.cc | 28 +- tests/grib_ieee.cc | 12 +- tests/grib_keys_iter.cc | 28 +- tests/grib_keys_iter_skip.cc | 10 +- tests/grib_local_MeteoFrance.cc | 2 +- tests/grib_multi_from_message.cc | 6 +- tests/grib_packing_order.cc | 4 +- tests/grib_partial_message.cc | 12 +- tests/grib_set_bytes.cc | 12 +- tests/grib_set_force.cc | 12 +- tests/grib_sh_imag.cc | 2 +- tests/grib_spectral.cc | 16 +- tests/grib_unpack_subarray.cc | 16 +- tests/grib_update_sections_lengths.cc | 4 +- tests/grib_util_set_spec.cc | 60 +-- tests/grib_util_set_spec2.cc | 18 +- tests/ibm.cc | 6 +- tests/julian.cc | 32 +- tests/unit_tests.cc | 390 +++++++++--------- tools/bufr_compare.cc | 4 +- tools/bufr_dump.cc | 12 +- tools/bufr_split_by_rdbSubtype.cc | 2 +- tools/grib2ppm.cc | 2 +- tools/grib_check_gaussian_grid.cc | 10 +- tools/grib_compare.cc | 2 +- tools/grib_dump.cc | 2 +- tools/grib_to_netcdf.cc | 62 +-- tools/grib_tools.cc | 12 +- tools/gts_compare.cc | 4 +- tools/metar_compare.cc | 4 +- tools/metar_copy.cc | 2 +- 197 files changed, 916 insertions(+), 916 deletions(-) diff --git a/fortran/grib_fortran.cc b/fortran/grib_fortran.cc index 1f9af48c6..ccf5257e5 100644 --- a/fortran/grib_fortran.cc +++ b/fortran/grib_fortran.cc @@ -237,7 +237,7 @@ static int push_file(FILE* f, const char* open_mode, char* buffer) if(!file_set){ file_set = (l_grib_file*)malloc(sizeof(l_grib_file)); - Assert(file_set); + ECCODES_ASSERT(file_set); file_set->id = myindex; file_set->f = f; file_set->mode = fmode; @@ -261,7 +261,7 @@ static int push_file(FILE* f, const char* open_mode, char* buffer) } the_new = (l_grib_file*)malloc(sizeof(l_grib_file)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->f = f; the_new->mode = fmode; @@ -294,7 +294,7 @@ static void _push_handle(grib_handle *h,int *gid) if(!handle_set){ handle_set = (l_grib_handle*)malloc(sizeof(l_grib_handle)); - Assert(handle_set); + ECCODES_ASSERT(handle_set); handle_set->id = myindex; handle_set->h = h; handle_set->next = NULL; @@ -319,7 +319,7 @@ static void _push_handle(grib_handle *h,int *gid) } the_new = (l_grib_handle*)malloc(sizeof(l_grib_handle)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->h = h; the_new->next = current; @@ -352,7 +352,7 @@ static void _push_index(grib_index *h,int *gid) if(!index_set){ index_set = (l_grib_index*)malloc(sizeof(l_grib_index)); - Assert(index_set); + ECCODES_ASSERT(index_set); index_set->id = myindex; index_set->h = h; index_set->next = NULL; @@ -377,7 +377,7 @@ static void _push_index(grib_index *h,int *gid) } the_new = (l_grib_index*)malloc(sizeof(l_grib_index)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->h = h; the_new->next = current; @@ -410,7 +410,7 @@ static void _push_multi_handle(grib_multi_handle *h,int *gid) if(!multi_handle_set){ multi_handle_set = (l_grib_multi_handle*)malloc(sizeof(l_grib_multi_handle)); - Assert(multi_handle_set); + ECCODES_ASSERT(multi_handle_set); multi_handle_set->id = myindex; multi_handle_set->h = h; multi_handle_set->next = NULL; @@ -435,7 +435,7 @@ static void _push_multi_handle(grib_multi_handle *h,int *gid) } the_new = (l_grib_multi_handle*)malloc(sizeof(l_grib_multi_handle)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->h = h; the_new->next = current; @@ -481,7 +481,7 @@ static int _push_keys_iterator(grib_keys_iterator *i) if(!keys_iterator_set){ keys_iterator_set = (l_grib_keys_iterator*)malloc(sizeof(l_grib_keys_iterator)); - Assert(keys_iterator_set); + ECCODES_ASSERT(keys_iterator_set); keys_iterator_set->id = myindex; keys_iterator_set->i = i; keys_iterator_set->next = NULL; @@ -503,7 +503,7 @@ static int _push_keys_iterator(grib_keys_iterator *i) if(!previous) return -1; the_new = (l_grib_keys_iterator*)malloc(sizeof(l_grib_keys_iterator)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->i = i; the_new->next = current; @@ -532,7 +532,7 @@ static int _push_bufr_keys_iterator(bufr_keys_iterator *i) if(!bufr_keys_iterator_set){ bufr_keys_iterator_set = (l_bufr_keys_iterator*)malloc(sizeof(l_bufr_keys_iterator)); - Assert(bufr_keys_iterator_set); + ECCODES_ASSERT(bufr_keys_iterator_set); bufr_keys_iterator_set->id = myindex; bufr_keys_iterator_set->i = i; bufr_keys_iterator_set->next = NULL; @@ -554,7 +554,7 @@ static int _push_bufr_keys_iterator(bufr_keys_iterator *i) if(!previous) return -1; the_new = (l_bufr_keys_iterator*)malloc(sizeof(l_bufr_keys_iterator)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->i = i; the_new->next = current; @@ -1020,7 +1020,7 @@ static int _push_iterator(grib_iterator *i) if(!iterator_set){ iterator_set = (l_grib_iterator*)malloc(sizeof(l_grib_iterator)); - Assert(iterator_set); + ECCODES_ASSERT(iterator_set); iterator_set->id = myindex; iterator_set->i = i; iterator_set->next = NULL; @@ -1041,7 +1041,7 @@ static int _push_iterator(grib_iterator *i) } the_new = (l_grib_iterator*)malloc(sizeof(l_grib_iterator)); - Assert(the_new); + ECCODES_ASSERT(the_new); the_new->id = myindex; the_new->i = i; the_new->next = current; @@ -1281,7 +1281,7 @@ static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) *iterid=-1; return GRIB_NULL_HANDLE; } - Assert(h->product_kind==PRODUCT_BUFR); + ECCODES_ASSERT(h->product_kind==PRODUCT_BUFR); iter=codes_bufr_keys_iterator_new(h,0); if (iter) *iterid=push_bufr_keys_iterator(iter); @@ -2883,14 +2883,14 @@ int codes_f_bufr_multi_element_constant_arrays_off_(void) /*****************************************************************************/ void grib_f_set_debug_(int* dmode) { - Assert(dmode); + ECCODES_ASSERT(dmode); grib_context* c = grib_context_get_default(); grib_context_set_debug(c, *dmode); } /*****************************************************************************/ void grib_f_set_data_quality_checks_(int* val) { - Assert(val); + ECCODES_ASSERT(val); grib_context* c = grib_context_get_default(); grib_context_set_data_quality_checks(c, *val); } diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc index 244ec79b0..0fd3e7b0b 100644 --- a/src/accessor/grib_accessor_class_ascii.cc +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -17,7 +17,7 @@ void grib_accessor_ascii_t::init(const long len, grib_arguments* arg) { grib_accessor_gen_t::init(len, arg); length_ = len; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } int grib_accessor_ascii_t::value_count(long* count) diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index b7627f86c..8c0bf73e0 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -26,10 +26,10 @@ void grib_accessor_bitmap_t::compute_size() grib_accessor* seclen; size_t size; /* Assume reparsing */ - Assert(hand->loader != 0); + ECCODES_ASSERT(hand->loader != 0); if (hand->loader != 0) { seclen = grib_find_accessor(hand, sLength_); - Assert(seclen); + ECCODES_ASSERT(seclen); grib_get_block_length(seclen->parent_, &size); slen = size; } @@ -41,11 +41,11 @@ void grib_accessor_bitmap_t::compute_size() if (length_ < 0) { /* Assume reparsing */ - /*Assert(hand->loader != 0);*/ + /*ECCODES_ASSERT(hand->loader != 0);*/ length_ = 0; } - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } void grib_accessor_bitmap_t::init(const long len, grib_arguments* arg) diff --git a/src/accessor/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc index b03255af3..7e2ee2711 100644 --- a/src/accessor/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -39,7 +39,7 @@ void grib_accessor_bits_t::init(const long l, grib_arguments* c) scale_ = c->get_double(hand, n++); } - Assert(len_ <= sizeof(long) * 8); + ECCODES_ASSERT(len_ <= sizeof(long) * 8); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index d578f53a6..d038a1ce4 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -18,7 +18,7 @@ void grib_accessor_blob_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); grib_get_long_internal(grib_handle_of_accessor(this), arg->get_name(parent_->h, 0), &length_); - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } long grib_accessor_blob_t::get_native_type() diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc index 8488b1af4..41d128eae 100644 --- a/src/accessor/grib_accessor_class_budgdate.cc +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -67,7 +67,7 @@ int grib_accessor_budgdate_t::pack_long(const long* val, size_t* len) year -= 1900; - Assert(year < 255); + ECCODES_ASSERT(year < 255); if ((ret = grib_set_long_internal(grib_handle_of_accessor(this), day_, day)) != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index 3d49d9a5b..070fc038e 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -225,7 +225,7 @@ void grib_accessor_bufr_data_array_t::init(const long v, grib_arguments* params) bitsToEndData_ = get_length() * 8; unpackMode_ = CODES_BUFR_UNPACK_STRUCTURE; inputBitmap_ = NULL; - /* Assert(length_ >=0); */ + /* ECCODES_ASSERT(length_ >=0); */ } // void clean_string(char* s,int len) @@ -932,7 +932,7 @@ int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s double cdval = 0, x; int err = 0; bufr_descriptor* bd = descriptor == NULL ? self->expanded_->v[i] : descriptor; - /* Assert( b->data == data); */ + /* ECCODES_ASSERT( b->data == data); */ if (self->change_ref_value_operand_ > 0 && self->change_ref_value_operand_ != 255) { /* Operator 203YYY: Change Reference Values: Definition phase */ @@ -1012,7 +1012,7 @@ int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, i err = &ret; descriptors = self->expanded_->v; - /* Assert(buff->data == data); */ + /* ECCODES_ASSERT(buff->data == data); */ grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data decoding: -%d- \tcode=%6.6ld width=%ld ", i, self->expanded_->v[i]->code, self->expanded_->v[i]->width); @@ -1098,7 +1098,7 @@ int grib_accessor_bufr_data_array_t::encode_overridden_reference_value(grib_cont long currRefVal = -1; long numBits = change_ref_value_operand_; /* We must be encoding between 203YYY and 203255 */ - Assert(change_ref_value_operand_ > 0 && change_ref_value_operand_ != 255); + ECCODES_ASSERT(change_ref_value_operand_ > 0 && change_ref_value_operand_ != 255); if (refValListSize_ == 0) { grib_context_log(c, GRIB_LOG_ERROR, "encode_new_element: Overridden Reference Values array is empty! " @@ -1262,7 +1262,7 @@ int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int s int idx, j; int err = 0; bufr_descriptor* bd = descriptor == NULL ? self->expanded_->v[i] : descriptor; - /* Assert( buff->data == data); */ + /* ECCODES_ASSERT( buff->data == data); */ grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data encoding: -%d- \tcode=%6.6ld width=%ld pos=%ld ulength=%ld ulength_bits=%ld", i, bd->code, bd->width, (long)*pos, buff->ulength, buff->ulength_bits); @@ -1332,7 +1332,7 @@ int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, i grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { - /* Assert( buff->data == data); */ + /* ECCODES_ASSERT( buff->data == data); */ if (self->compressedData_) { DEBUG_ASSERT(grib_darray_used_size(self->numericValues_->v[elementIndex]) == 1); *numberOfRepetitions = self->numericValues_->v[elementIndex]->v[0]; @@ -1388,7 +1388,7 @@ int grib_accessor_bufr_data_array_t::build_bitmap(unsigned char* data, long* pos i = iBitmapOperator + 1; if (descriptors[i]->code == 101000) { iDelayedReplication = iBitmapOperator + 2; - Assert(descriptors[iDelayedReplication]->code == 31001 || + ECCODES_ASSERT(descriptors[iDelayedReplication]->code == 31001 || descriptors[iDelayedReplication]->code == 31002); i = iDelayedReplication; if (compressedData_) { @@ -1458,7 +1458,7 @@ int grib_accessor_bufr_data_array_t::consume_bitmap(int iBitmapOperator) bitmapSize = inputExtendedReplications_[iInputExtendedReplications_]; break; default: - Assert(0); + ECCODES_ASSERT(0); } } else if (descriptors[i]->code == 31031) { @@ -1528,7 +1528,7 @@ int grib_accessor_bufr_data_array_t::build_bitmap_new_data(unsigned char* data, bitmapSize = inputExtendedReplications_[iInputExtendedReplications_]; break; default: - Assert(0); + ECCODES_ASSERT(0); } } else if (descriptors[i]->code == 31031) { @@ -2043,10 +2043,10 @@ grib_iarray* grib_accessor_bufr_data_array_t::set_subset_list( #ifdef DEBUG if (subsetList == NULL) { - Assert(subsetListSize == 0); + ECCODES_ASSERT(subsetListSize == 0); } if (subsetListSize == 0) { - Assert(subsetList == NULL); + ECCODES_ASSERT(subsetList == NULL); } #endif if (startSubset > 0) { diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index 69cef9407..fdf5056e0 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -476,7 +476,7 @@ int grib_accessor_bufr_data_element_t::is_missing() err = unpack_long(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); if (size > 1) { for (i = 0; i < size; i++) { if (!grib_is_missing_long(this, values[i])) { @@ -504,7 +504,7 @@ int grib_accessor_bufr_data_element_t::is_missing() err = unpack_double(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); if (size > 1) { for (i = 0; i < size; ++i) { if (!grib_is_missing_double(this, values[i])) { diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc index 233dfc118..a2349914c 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -234,8 +234,8 @@ int grib_accessor_bufr_elements_table_t::bufr_get_from_table(bufr_descriptor* v) /* ECC-1137: check descriptor key name and unit lengths */ const size_t maxlen_shortName = sizeof(v->shortName); const size_t maxlen_units = sizeof(v->units); - Assert(strlen(list[1]) < maxlen_shortName); - Assert(strlen(list[4]) < maxlen_units); + ECCODES_ASSERT(strlen(list[1]) < maxlen_shortName); + ECCODES_ASSERT(strlen(list[4]) < maxlen_units); } #endif diff --git a/src/accessor/grib_accessor_class_bytes.cc b/src/accessor/grib_accessor_class_bytes.cc index 6ae039dcd..5421cc780 100644 --- a/src/accessor/grib_accessor_class_bytes.cc +++ b/src/accessor/grib_accessor_class_bytes.cc @@ -18,7 +18,7 @@ void grib_accessor_bytes_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ length_ = len; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } long grib_accessor_bytes_t::get_native_type() @@ -93,7 +93,7 @@ int grib_accessor_bytes_t::pack_string(const char* val, size_t* len) grib_context_free(c, bytearray); return GRIB_INVALID_KEY_VALUE; } - Assert(byteVal < 256); + ECCODES_ASSERT(byteVal < 256); bytearray[i] = (int)byteVal; } diff --git a/src/accessor/grib_accessor_class_cf_var_name.cc b/src/accessor/grib_accessor_class_cf_var_name.cc index 072a3ba49..11f9ef12c 100644 --- a/src/accessor/grib_accessor_class_cf_var_name.cc +++ b/src/accessor/grib_accessor_class_cf_var_name.cc @@ -29,8 +29,8 @@ int grib_accessor_cf_var_name_t::unpack_string(char* val, size_t* len) int err = grib_get_string(h, defaultKey_, defaultKey, &size); if (err) return err; - Assert(size > 0); - Assert(strlen(defaultKey) > 0); + ECCODES_ASSERT(size > 0); + ECCODES_ASSERT(strlen(defaultKey) > 0); if (STR_EQUAL(defaultKey, "~") || isdigit(defaultKey[0])) { // NetCDF variables cannot start with a digit diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc index c6446562e..bee9e7a2d 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -91,8 +91,8 @@ int grib_accessor_change_scanning_direction_t::pack_long(const long* val, size_t return err; } - Assert(axis_); - Assert(strcmp(axis_, "x") == 0 || strcmp(axis_, "y") == 0); + ECCODES_ASSERT(axis_); + ECCODES_ASSERT(strcmp(axis_, "x") == 0 || strcmp(axis_, "y") == 0); if (axis_[0] == 'x') { theEnd = Ni / 2; diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc index ef16d6176..873c24451 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.cc +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -26,7 +26,7 @@ void grib_accessor_check_internal_version_t::init(const long l, grib_arguments* long defs_file_version = 0; grib_handle* h = grib_handle_of_accessor(this); const char* s_defn_version = args->get_name(h, 0); - Assert(s_defn_version); + ECCODES_ASSERT(s_defn_version); err = grib_get_long_internal(h, s_defn_version, &defs_file_version); if (!err) { diff --git a/src/accessor/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc index 5f78d1fc3..138c642a4 100644 --- a/src/accessor/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -69,7 +69,7 @@ int grib_accessor_closest_date_t::unpack_double(double* val, size_t* len) *val = -1; /* initialise to an invalid index */ if ((err = grib_get_long_internal(h, numForecasts_, &num_forecasts)) != GRIB_SUCCESS) return err; - Assert(num_forecasts > 1); + ECCODES_ASSERT(num_forecasts > 1); if ((err = grib_get_long(h, dateLocal_, &ymdLocal)) != GRIB_SUCCESS) return err; yearLocal = ymdLocal / 10000; @@ -86,32 +86,32 @@ int grib_accessor_closest_date_t::unpack_double(double* val, size_t* len) secondLocal = hmsLocal; if ((err = grib_get_size(h, year_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); yearArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, year_, yearArray, &size)) != GRIB_SUCCESS) return err; if ((err = grib_get_size(h, month_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); monthArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, month_, monthArray, &size)) != GRIB_SUCCESS) return err; if ((err = grib_get_size(h, day_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); dayArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, day_, dayArray, &size)) != GRIB_SUCCESS) return err; if ((err = grib_get_size(h, hour_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); hourArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, hour_, hourArray, &size)) != GRIB_SUCCESS) return err; if ((err = grib_get_size(h, minute_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); minuteArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, minute_, minuteArray, &size)) != GRIB_SUCCESS) return err; if ((err = grib_get_size(h, second_, &size)) != GRIB_SUCCESS) return err; - Assert(size == (size_t)num_forecasts); + ECCODES_ASSERT(size == (size_t)num_forecasts); secondArray = (long*)grib_context_malloc_clear(c, size * sizeof(long)); if ((err = grib_get_long_array_internal(h, second_, secondArray, &size)) != GRIB_SUCCESS) return err; diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 4345b11cc..a0943868f 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -18,7 +18,7 @@ void grib_accessor_codeflag_t::init(const long len, grib_arguments* param) grib_accessor_unsigned_t::init(len, param); length_ = len; tablename_ = param->get_string(grib_handle_of_accessor(this), 0); - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } static int test_bit(long a, long b) diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index 56941b2d3..3d05a7198 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -80,7 +80,7 @@ void grib_accessor_codetable_t::init(const long len, grib_arguments* params) #ifdef DEBUG if (flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { grib_context_log(context_, GRIB_LOG_FATAL, "codetable '%s' has flag can_be_missing!", name_); - Assert(!"codetable with can_be_missing?"); + ECCODES_ASSERT(!"codetable with can_be_missing?"); } #endif @@ -232,7 +232,7 @@ grib_codetable* grib_accessor_codetable_t::load_table() } if (flags_ & GRIB_ACCESSOR_FLAG_TRANSIENT) { - Assert(vvalue_ != NULL); + ECCODES_ASSERT(vvalue_ != NULL); size = vvalue_->length * 8; } else { @@ -276,7 +276,7 @@ static int grib_load_codetable(grib_context* c, const char* filename, if (!f) return GRIB_IO_PROBLEM; - Assert(t != NULL); + ECCODES_ASSERT(t != NULL); if (t->filename[0] == NULL) { t->filename[0] = grib_context_strdup_persistent(c, filename); @@ -324,7 +324,7 @@ static int grib_load_codetable(grib_context* c, const char* filename, grib_context_log(c, GRIB_LOG_ERROR, "Invalid entry in file %s: line %d", filename, lineNumber); continue; /* skip this line */ } - Assert(isdigit(*p)); + ECCODES_ASSERT(isdigit(*p)); while (*p != '\0') { if (isspace(*p)) @@ -372,8 +372,8 @@ static int grib_load_codetable(grib_context* c, const char* filename, if (!units) units = unknown; - Assert(*abbreviation); - Assert(*title); + ECCODES_ASSERT(*abbreviation); + ECCODES_ASSERT(*title); string_rtrim(title); /* ECC-1315 */ if (t->entries[code].abbreviation != NULL) { @@ -381,8 +381,8 @@ static int grib_load_codetable(grib_context* c, const char* filename, continue; } - Assert(t->entries[code].abbreviation == NULL); - Assert(t->entries[code].title == NULL); + ECCODES_ASSERT(t->entries[code].abbreviation == NULL); + ECCODES_ASSERT(t->entries[code].title == NULL); t->entries[code].abbreviation = grib_context_strdup_persistent(c, abbreviation); t->entries[code].title = grib_context_strdup_persistent(c, title); @@ -631,7 +631,7 @@ bool strings_equal(const char* s1, const char* s2, bool case_sensitive) int grib_accessor_codetable_t::pack_string(const char* buffer, size_t* len) { long lValue = 0; - Assert(buffer); + ECCODES_ASSERT(buffer); if (is_number(buffer) && string_to_long(buffer, &lValue, 1) == GRIB_SUCCESS) { // ECC-1654: If value is a pure number, just pack as long size_t l = 1; @@ -786,8 +786,8 @@ int grib_accessor_codetable_t::unpack_long(long* val, size_t* len) #ifdef DEBUG { int err = value_count(&rlen); - Assert(!err); - Assert(rlen == 1); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(rlen == 1); } #endif rlen = 1; /* ECC-480 Performance: avoid func call overhead of grib_value_count */ diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index c8c651e87..6b9313122 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -200,7 +200,7 @@ static int concept_conditions_expression_apply(grib_handle* h, grib_concept_cond size_t size; int err = 0; - Assert(count < 1024); + ECCODES_ASSERT(count < 1024); values[count].name = e->name; values[count].type = e->expression->native_type(h); diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index dac3a40c3..1e74935a0 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -150,7 +150,7 @@ int grib_accessor_data_apply_bitmap_t::unpack_double_element_set(const size_t* i for (j = 0; j < idx; j++) { cidx += bvals[j]; } - Assert(ci < count_1s); + ECCODES_ASSERT(ci < count_1s); cidx_array[ci++] = cidx; } } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index 0e10ef715..4957d361a 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -90,7 +90,7 @@ int grib_accessor_data_apply_boustrophedonic_t::unpack(T* val, size_t* len) return ret; if (grib_get_size(grib_handle_of_accessor(this), pl_, &plSize) == GRIB_SUCCESS) { - Assert(plSize == numberOfRows); + ECCODES_ASSERT(plSize == numberOfRows); pl = (long*)grib_context_malloc_clear(context_, sizeof(long) * plSize); ret = grib_get_long_array_internal(grib_handle_of_accessor(this), pl_, pl, &plSize); if (ret) @@ -228,7 +228,7 @@ int grib_accessor_data_apply_boustrophedonic_t::pack_double(const double* val, s return ret; if (grib_get_size(grib_handle_of_accessor(this), pl_, &plSize) == GRIB_SUCCESS) { - Assert(plSize == numberOfRows); + ECCODES_ASSERT(plSize == numberOfRows); pl = (long*)grib_context_malloc_clear(context_, sizeof(long) * plSize); ret = grib_get_long_array_internal(grib_handle_of_accessor(this), pl_, pl, &plSize); if (ret) diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index 7fe6a0323..81b64e663 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -43,7 +43,7 @@ int grib_accessor_data_apply_boustrophedonic_bitmap_t::value_count(long* count) int ret = 0; /* This accessor is for data with a bitmap after all */ - Assert(grib_find_accessor(gh, bitmap_)); + ECCODES_ASSERT(grib_find_accessor(gh, bitmap_)); ret = grib_get_size(gh, bitmap_, &len); *count = len; @@ -76,7 +76,7 @@ int grib_accessor_data_apply_boustrophedonic_bitmap_t::unpack_double(double* val err = grib_get_long_internal(gh, numberOfPoints_, &numberOfPoints); if (err) return err; - Assert(nn == numberOfPoints); + ECCODES_ASSERT(nn == numberOfPoints); if (!grib_find_accessor(gh, bitmap_)) return grib_get_double_array_internal(gh, coded_values_, val, len); @@ -263,7 +263,7 @@ int grib_accessor_data_apply_boustrophedonic_bitmap_t::unpack_double_element_set for (j = 0; j < idx; j++) { cidx += bvals[j]; } - Assert(ci < count_1s); + ECCODES_ASSERT(ci < count_1s); cidx_array[ci++] = cidx; } } @@ -322,7 +322,7 @@ int grib_accessor_data_apply_boustrophedonic_bitmap_t::pack_double(const double* err = grib_get_long_internal(gh, numberOfPoints_, &numberOfPoints); if (err) return err; - Assert(numberOfPoints == bmaplen); + ECCODES_ASSERT(numberOfPoints == bmaplen); /* Create a copy of the incoming 'val' array because we're going to change it */ values = (double*)grib_context_malloc_clear(context_, sizeof(double) * numberOfPoints); diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 01b826343..3aea1ea15 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -168,7 +168,7 @@ int grib_accessor_data_ccsds_packing_t::pack_double(const double* val, size_t* l if (is_constant_field) { #ifdef DEBUG for (i = 1; i < n_vals; i++) { - Assert(val[i] == val[0]); + ECCODES_ASSERT(val[i] == val[0]); } #endif if (grib_get_nearest_smaller_value(hand, reference_value_, val[0], &reference_value) != GRIB_SUCCESS) { diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index b48b6179c..0a3f631ab 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -132,7 +132,7 @@ double calculate_pfactor(const grib_context* ctx, const double* spectralField, l */ for (loop = ismin; loop <= ismax; loop++) { x = log((double)(loop * (loop + 1))); - Assert(norms[loop] > 0); + ECCODES_ASSERT(norms[loop] > 0); y = log(norms[loop]); weightedSumOverX = weightedSumOverX + x * weights[loop]; weightedSumOverY = weightedSumOverY + y * weights[loop]; @@ -743,7 +743,7 @@ int grib_accessor_data_complex_packing_t::unpack_real(T* val, size_t* len) mmax++; } - //Assert(*len >= i); + //ECCODES_ASSERT(*len >= i); if (*len < i) { grib_context_log(context_, GRIB_LOG_ERROR, "%s::%s: Invalid values *len=%zu and i=%zu.", class_name_, __func__, *len, i); diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc index 7f0deff36..1382cfc0c 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -71,7 +71,7 @@ int grib_accessor_data_g1complex_packing_t::pack_double(const double* val, size_ dirty_ = 1; - Assert((sub_j == sub_k) && (sub_m == sub_j)); + ECCODES_ASSERT((sub_j == sub_k) && (sub_m == sub_j)); ret = grib_accessor_data_complex_packing_t::pack_double(val, len); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 84ea910c5..2f23bae67 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -199,7 +199,7 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::unpack(double* long bias = 0; long y = 0, z = 0, w = 0; size_t k, ngroups; - Assert(!(dvalues && fvalues)); + ECCODES_ASSERT(!(dvalues && fvalues)); if (dvalues) { if (!double_dirty_) { @@ -694,7 +694,7 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co break; } if (orderOfSPD) { - Assert(orderOfSPD >= 0 && orderOfSPD < numberOfValues); + ECCODES_ASSERT(orderOfSPD >= 0 && orderOfSPD < numberOfValues); bias = X[orderOfSPD]; for (i = orderOfSPD + 1; i < numberOfValues; i++) { if (bias > X[i]) @@ -1143,7 +1143,7 @@ int grib_accessor_data_g1second_order_general_extended_packing_t::pack_double(co 0, }; size_t nSPD = orderOfSPD + 1; - Assert(orderOfSPD <= 3); + ECCODES_ASSERT(orderOfSPD <= 3); for (i = 0; i < orderOfSPD; i++) SPD[i] = X[i]; SPD[orderOfSPD] = bias; diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc index 7bd009775..869a595d6 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -108,7 +108,7 @@ int grib_accessor_data_g1secondary_bitmap_t::pack_double(const double* val, size *len = k; /*printf("QQQQQQQ %ld %ld second=%ld\n",primary_len,on,m);*/ - Assert(k == primary_len); + ECCODES_ASSERT(k == primary_len); err = grib_set_double_array_internal(grib_handle_of_accessor(this), primary_bitmap_, primary_bitmap, k); if (err == GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc index 4ebc9ca12..ffacd5035 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -193,7 +193,7 @@ int grib_accessor_data_g1simple_packing_t::pack_double(const double* cval, size_ "HALF byte: buflen=%d bits_per_value=%ld len=%d half_byte=%ld\n", buflen, bits_per_value, *len, half_byte); - Assert(half_byte <= 0x0f); + ECCODES_ASSERT(half_byte <= 0x0f); if ((ret = grib_set_long_internal(grib_handle_of_accessor(this), half_byte_, half_byte)) != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index c6d50bbae..74f1583fe 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -305,8 +305,8 @@ static int min_max_array(double* data, unsigned int n, double* min, double* max) static int post_process(grib_context* c, long* vals, long len, long order, long bias, const unsigned long extras[2]) { unsigned long last, penultimate = 0, j = 0; - Assert(order > 0); - Assert(order <= 3); + ECCODES_ASSERT(order > 0); + ECCODES_ASSERT(order <= 3); if (!vals) return GRIB_INTERNAL_ERROR; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index eee26fb16..8670fadbe 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -220,7 +220,7 @@ static double laplam(bif_trunc_t* bt, const double val[]) free(itab2); return 0.; } - Assert(lmax > 0); + ECCODES_ASSERT(lmax > 0); /* * Now, itab2 contains all possible values of i*i+j*j, and itab1 contains @@ -527,7 +527,7 @@ int grib_accessor_data_g2bifourier_packing_t::unpack_double(double* val, size_t* isp += 4; } - Assert(*len >= isp); + ECCODES_ASSERT(*len >= isp); *len = isp; cleanup: diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc index 519a15557..a9481bdec 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -89,7 +89,7 @@ int grib_accessor_data_g2secondary_bitmap_t::pack_double(const double* val, size *len = k; - Assert(k == primary_len); + ECCODES_ASSERT(k == primary_len); err = grib_set_double_array_internal(grib_handle_of_accessor(this), primary_bitmap_, primary_bitmap, k); if (err == GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index a6a083046..a7fb0ac66 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -36,7 +36,7 @@ static int pre_processing_func(double* values, long length, long pre_processing, int i = 0, ret = 0; double min = values[0]; double next_min = values[0]; - Assert(length > 0); + ECCODES_ASSERT(length > 0); switch (pre_processing) { /* NONE */ @@ -75,7 +75,7 @@ static int pre_processing_func(double* values, long length, long pre_processing, } } else { - Assert(mode == INVERSE); + ECCODES_ASSERT(mode == INVERSE); if (*pre_processing_parameter == 0) { for (i = 0; i < length; i++) values[i] = exp(values[i]); diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index 46bee7a76..9d7e9a90a 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -62,7 +62,7 @@ void grib_accessor_data_jpeg2000_packing_t::init(const long v, grib_arguments* a fprintf(stderr, "ECCODES DEBUG jpeg2000_packing: using OPENJPEG_LIB\n"); break; default: - Assert(0); + ECCODES_ASSERT(0); break; } } @@ -352,8 +352,8 @@ int grib_accessor_data_jpeg2000_packing_t::pack_double(const double* cval, size_ class_name_, __func__, type_of_compression_used, target_compression_ratio_); return GRIB_ENCODING_ERROR; } - Assert(target_compression_ratio != 255); - Assert(target_compression_ratio != 0); + ECCODES_ASSERT(target_compression_ratio != 255); + ECCODES_ASSERT(target_compression_ratio != 0); helper.compression = target_compression_ratio; break; @@ -401,7 +401,7 @@ int grib_accessor_data_jpeg2000_packing_t::pack_double(const double* cval, size_ class_name_, jpeg_lib_ == OPENJPEG_LIB ? "openjpeg" : "jasper", helper.jpeg_length, simple_packing_size); - Assert(helper.jpeg_length <= helper.buffer_size); + ECCODES_ASSERT(helper.jpeg_length <= helper.buffer_size); if (dump_jpg_) { FILE* f = fopen(dump_jpg_, "w"); diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index 13d032431..bbfdff7ed 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -54,7 +54,7 @@ typedef struct png_read_callback_data static void png_read_callback(png_structp png, png_bytep data, png_size_t length) { png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); - Assert(p->offset + length <= p->length); + ECCODES_ASSERT(p->offset + length <= p->length); memcpy(data, p->buffer + p->offset, length); p->offset += length; } @@ -63,7 +63,7 @@ static void png_write_callback(png_structp png, png_bytep data, png_size_t lengt { png_read_callback_data* p = (png_read_callback_data*)png_get_io_ptr(png); /* printf("p.offset=%zu len=%zu p.len=%zu\n", p->offset, length, p->length); */ - /* Assert(p->offset + length <= p->length); */ + /* ECCODES_ASSERT(p->offset + length <= p->length); */ if (p->offset + length > p->length) { /* Errors handled through png_error() are fatal, meaning that png_error() should never return to its caller. Currently, this is handled via setjmp() and longjmp() */ @@ -174,7 +174,7 @@ int grib_accessor_data_png_packing_t::unpack_double(double* val, size_t* len) png_set_read_fn(png, &callback_data, png_read_callback); png_read_png(png, info, PNG_TRANSFORM_IDENTITY, NULL); - Assert(callback_data.offset == callback_data.length); + ECCODES_ASSERT(callback_data.offset == callback_data.length); rows = png_get_rows(png, info); @@ -192,9 +192,9 @@ int grib_accessor_data_png_packing_t::unpack_double(double* val, size_t* len) bits8 = ((bits_per_value + 7) / 8) * 8; #ifdef PNG_ANYBITS - Assert(depth == bits8); + ECCODES_ASSERT(depth == bits8); #else - Assert(bits_per_value % 8 == 0); + ECCODES_ASSERT(bits_per_value % 8 == 0); #endif i = 0; @@ -296,7 +296,7 @@ int grib_accessor_data_png_packing_t::pack_double(const double* val, size_t* len if (is_constant_field) { #ifdef DEBUG for (i = 1; i < n_vals; i++) { - Assert(val[i] == val[0]); + ECCODES_ASSERT(val[i] == val[0]); } #endif if ((err = grib_set_double_internal(grib_handle_of_accessor(this), reference_value_, val[0])) != GRIB_SUCCESS) @@ -399,7 +399,7 @@ int grib_accessor_data_png_packing_t::pack_double(const double* val, size_t* len divisor = codes_power(-binary_scale_factor, 2); #ifndef PNG_ANYBITS - Assert(bits_per_value % 8 == 0); + ECCODES_ASSERT(bits_per_value % 8 == 0); #endif bits8 = (bits_per_value + 7) / 8 * 8; encoded = (unsigned char*)grib_context_buffer_malloc_clear(context_, bits8 / 8 * n_vals); @@ -511,7 +511,7 @@ int grib_accessor_data_png_packing_t::pack_double(const double* val, size_t* len png_write_png(png, info, PNG_TRANSFORM_IDENTITY, NULL); - Assert(callback_data.offset <= callback_data.length); + ECCODES_ASSERT(callback_data.offset <= callback_data.length); grib_buffer_replace(this, buf, callback_data.offset, 1, 1); diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc index 4da85f02e..78d82bac3 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -171,7 +171,7 @@ int grib_accessor_data_raw_packing_t::unpack_double_element(size_t idx, double* pos = bytes * idx; - Assert(pos <= inlen); + ECCODES_ASSERT(pos <= inlen); nvals = 1; buf += pos; diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc index 3b658b84d..31fd3e4c5 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -98,8 +98,8 @@ int grib_accessor_data_secondary_bitmap_t::unpack_double(double* val, size_t* le } } - Assert(k <= *len); - Assert(m <= secondary_len); + ECCODES_ASSERT(k <= *len); + ECCODES_ASSERT(m <= secondary_len); /*printf("FOOBAR %d %d %ld %d\n",f,primary_len,expand_by,n_vals);*/ diff --git a/src/accessor/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc index 4d5656a4f..9e07bd79c 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -167,10 +167,10 @@ int grib_accessor_data_sh_packed_t::unpack_double(double* val, size_t* len) return GRIB_NOT_IMPLEMENTED; } - Assert(sub_j == sub_k); - Assert(sub_j == sub_m); - Assert(pen_j == pen_k); - Assert(pen_j == pen_m); + ECCODES_ASSERT(sub_j == sub_k); + ECCODES_ASSERT(sub_j == sub_m); + ECCODES_ASSERT(pen_j == pen_k); + ECCODES_ASSERT(pen_j == pen_m); buf = (unsigned char*)grib_handle_of_accessor(this)->buffer->data; @@ -232,7 +232,7 @@ int grib_accessor_data_sh_packed_t::unpack_double(double* val, size_t* len) mmax++; } - Assert(*len >= i); + ECCODES_ASSERT(*len >= i); *len = n_vals; grib_context_free(context_, scals); diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc index dddf88083..328722283 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -54,7 +54,7 @@ int grib_accessor_data_sh_unpacked_t::value_count(long* count) if (sub_j != sub_k || sub_j != sub_m) { grib_context_log(context_, GRIB_LOG_ERROR, "sub_j=%ld, sub_k=%ld, sub_m=%ld\n", sub_j, sub_k, sub_m); - Assert((sub_j == sub_k) && (sub_j == sub_m)); + ECCODES_ASSERT((sub_j == sub_k) && (sub_j == sub_m)); } *count = (sub_j + 1) * (sub_j + 2); return ret; @@ -157,10 +157,10 @@ int grib_accessor_data_sh_unpacked_t::unpack_double(double* val, size_t* len) return GRIB_NOT_IMPLEMENTED; } - Assert(sub_j == sub_k); - Assert(sub_j == sub_m); - Assert(pen_j == pen_k); - Assert(pen_j == pen_m); + ECCODES_ASSERT(sub_j == sub_k); + ECCODES_ASSERT(sub_j == sub_m); + ECCODES_ASSERT(pen_j == pen_k); + ECCODES_ASSERT(pen_j == pen_m); buf = (unsigned char*)grib_handle_of_accessor(this)->buffer->data; @@ -178,7 +178,7 @@ int grib_accessor_data_sh_unpacked_t::unpack_double(double* val, size_t* len) d = codes_power(-decimal_scale_factor, 10); scals = (double*)grib_context_malloc(context_, maxv * sizeof(double)); - Assert(scals); + ECCODES_ASSERT(scals); if ((ret = grib_get_double_internal(grib_handle_of_accessor(this), laplacianOperator_, &laplacianOperator)) != GRIB_SUCCESS) return ret; @@ -225,7 +225,7 @@ int grib_accessor_data_sh_unpacked_t::unpack_double(double* val, size_t* len) mmax++; } - Assert(*len >= i); + ECCODES_ASSERT(*len >= i); *len = n_vals; grib_context_free(context_, scals); diff --git a/src/accessor/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc index 87c0cbcca..701e8196b 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -104,7 +104,7 @@ int grib_accessor_data_simple_packing_t::unpack_double_element(size_t idx, doubl return GRIB_SUCCESS; } - Assert(idx < n_vals); + ECCODES_ASSERT(idx < n_vals); s = codes_power(binary_scale_factor, 2); d = codes_power(-decimal_scale_factor, 10); @@ -113,7 +113,7 @@ int grib_accessor_data_simple_packing_t::unpack_double_element(size_t idx, doubl class_name_, __func__, name_, n_vals, idx); buf += byte_offset(); - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + /*ECCODES_ASSERT(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ if (bits_per_value % 8) { grib_context_log(context_, GRIB_LOG_DEBUG, @@ -244,7 +244,7 @@ int grib_accessor_data_simple_packing_t::unpack(T* val, size_t* len) offsetBeforeData = byte_offset(); buf += offsetBeforeData; - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + /*ECCODES_ASSERT(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ /* ECC-941 */ if (!context_->ieee_packing) { @@ -385,7 +385,7 @@ int grib_accessor_data_simple_packing_t::_unpack_double(double* val, size_t* len offsetBeforeData = byte_offset(); buf += offsetBeforeData; - /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ + /*ECCODES_ASSERT(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ /* ECC-941 */ if (!context_->ieee_packing) { diff --git a/src/accessor/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc index 7e53b6a00..05fd15bcc 100644 --- a/src/accessor/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -117,8 +117,8 @@ int grib_accessor_element_t::pack_long(const long* val, size_t* len) goto the_end; } - Assert(index >= 0); - Assert(index < size); + ECCODES_ASSERT(index >= 0); + ECCODES_ASSERT(index < size); ar[index] = *val; if ((ret = grib_set_long_array_internal(hand, array_, ar, size)) != GRIB_SUCCESS) @@ -164,8 +164,8 @@ int grib_accessor_element_t::pack_double(const double* v, size_t* len) goto the_end; } - Assert(index >= 0); - Assert(index < size); + ECCODES_ASSERT(index >= 0); + ECCODES_ASSERT(index < size); ar[index] = *v; if ((ret = grib_set_double_array_internal(hand, array_, ar, size)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index 7fe9b3e3a..7b1a90fe0 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -80,7 +80,7 @@ static const char* descriptor_type_name(int dtype) case BUFR_DESCRIPTOR_TYPE_SEQUENCE: return "sequence"; } - Assert(!"bufr_descriptor_type_name failed"); + ECCODES_ASSERT(!"bufr_descriptor_type_name failed"); return "unknown"; } #endif @@ -209,9 +209,9 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex #endif expanded = grib_bufr_descriptors_array_append(expanded, inner_expanded); uidx = grib_bufr_descriptors_array_get(expanded, idx); - Assert( uidx->type == BUFR_DESCRIPTOR_TYPE_REPLICATION ); - Assert( uidx->F == 1 ); - Assert( uidx->Y == 0 ); + ECCODES_ASSERT( uidx->type == BUFR_DESCRIPTOR_TYPE_REPLICATION ); + ECCODES_ASSERT( uidx->F == 1 ); + ECCODES_ASSERT( uidx->Y == 0 ); // ECC-1958 and ECC-1054: // Here X is used to store the size which can exceed 63. The normal X is 6 bits wide so max=63 // We need to set X but not the descriptor code @@ -533,7 +533,7 @@ int grib_accessor_expanded_descriptors_t::expand() if (!tablesAccessor_) { tablesAccessor_ = grib_find_accessor(h, tablesAccessorName_); - Assert(tablesAccessor_); + ECCODES_ASSERT(tablesAccessor_); } unexpanded = grib_bufr_descriptors_array_new(unexpandedSize, DESC_SIZE_INCR); @@ -549,7 +549,7 @@ int grib_accessor_expanded_descriptors_t::expand() /* ECC-433: Operator 206YYY */ if (aDescriptor1->F == 2 && aDescriptor1->X == 6) { - Assert(aDescriptor1->type == BUFR_DESCRIPTOR_TYPE_OPERATOR); + ECCODES_ASSERT(aDescriptor1->type == BUFR_DESCRIPTOR_TYPE_OPERATOR); operator206yyy_width = aDescriptor1->Y; /* Store the width for the following descriptor */ DEBUG_ASSERT(operator206yyy_width > 0); } diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc index 3071fdaa4..e24c927b3 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -138,7 +138,7 @@ int grib_accessor_g1forecastmonth_t::unpack_long_edition1(long* val, size_t* len if (check) { grib_context_log(context_, GRIB_LOG_ERROR, "%s=%ld (%s-%s)=%ld", fcmonth_, gribForecastMonth, base_date, verification_yearmonth_, fcmonth); - Assert(gribForecastMonth == fcmonth); + ECCODES_ASSERT(gribForecastMonth == fcmonth); } else { *val = gribForecastMonth; diff --git a/src/accessor/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc index 0d92b8311..2ef72fa5b 100644 --- a/src/accessor/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -589,7 +589,7 @@ int grib_accessor_g1step_range_t::pack_long(const long* val, size_t* len) } return pack_string(buff, &bufflen); default: - Assert(pack_index_ < 2); + ECCODES_ASSERT(pack_index_ < 2); break; } diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc index 4f0ad1c20..afb38ecff 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.cc +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -60,7 +60,7 @@ int grib_accessor_g2_aerosol_t::pack_long(const long* val, size_t* len) grib_get_long(hand, stream_ ,&stream); */ ret = grib_get_string(hand, stepType_, stepType, &slen); - Assert(ret == GRIB_SUCCESS); + ECCODES_ASSERT(ret == GRIB_SUCCESS); // eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); eps = grib_is_defined(hand, "perturbationNumber"); diff --git a/src/accessor/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc index 87cdbdb09..1a205ad76 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -38,7 +38,7 @@ int grib_accessor_g2_chemical_t::unpack_long(long* val, size_t* len) long productDefinitionTemplateNumber = 0; grib_get_long(grib_handle_of_accessor(this), productDefinitionTemplateNumber_, &productDefinitionTemplateNumber); - Assert(chemical_type_ == CHEM_PLAIN || chemical_type_ == CHEM_DISTRIB || chemical_type_ == CHEM_SRCSINK); + ECCODES_ASSERT(chemical_type_ == CHEM_PLAIN || chemical_type_ == CHEM_DISTRIB || chemical_type_ == CHEM_SRCSINK); if (chemical_type_ == CHEM_DISTRIB) *val = grib2_is_PDTN_ChemicalDistFunc(productDefinitionTemplateNumber); else if (chemical_type_ == CHEM_SRCSINK) @@ -70,7 +70,7 @@ int grib_accessor_g2_chemical_t::pack_long(const long* val, size_t* len) // grib_get_long(hand, type_ ,&type); // grib_get_long(hand, stream_ ,&stream); ret = grib_get_string(hand, stepType_, stepType, &slen); - Assert(ret == GRIB_SUCCESS); + ECCODES_ASSERT(ret == GRIB_SUCCESS); eps = grib_is_defined(hand, "perturbationNumber"); // eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); @@ -78,7 +78,7 @@ int grib_accessor_g2_chemical_t::pack_long(const long* val, size_t* len) if (!strcmp(stepType, "instant")) isInstant = 1; - Assert(chemical_type_ == CHEM_PLAIN || chemical_type_ == CHEM_DISTRIB || chemical_type_ == CHEM_SRCSINK); + ECCODES_ASSERT(chemical_type_ == CHEM_PLAIN || chemical_type_ == CHEM_DISTRIB || chemical_type_ == CHEM_SRCSINK); if (eps == 1) { if (isInstant) { diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index ab73d8e71..17ffa0a7d 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -76,7 +76,7 @@ static int convert_time_range_long_( long* lengthOfTimeRange /* time_range_value */ ) { - Assert(lengthOfTimeRange != NULL); + ECCODES_ASSERT(lengthOfTimeRange != NULL); if (indicatorOfUnitForTimeRange != stepUnits) { eccodes::Step time_range{ *lengthOfTimeRange, indicatorOfUnitForTimeRange }; @@ -337,10 +337,10 @@ int grib_accessor_g2end_step_t::unpack_long(long* val, size_t* len) return 0; } - Assert(numberOfTimeRanges_); + ECCODES_ASSERT(numberOfTimeRanges_); if ((ret = grib_get_long_internal(h, numberOfTimeRanges_, &numberOfTimeRanges))) return ret; - Assert(numberOfTimeRanges == 1 || numberOfTimeRanges == 2); + ECCODES_ASSERT(numberOfTimeRanges == 1 || numberOfTimeRanges == 2); try { if (numberOfTimeRanges == 1) { @@ -379,10 +379,10 @@ int grib_accessor_g2end_step_t::unpack_double(double* val, size_t* len) return 0; } - Assert(numberOfTimeRanges_); + ECCODES_ASSERT(numberOfTimeRanges_); if ((ret = grib_get_long_internal(h, numberOfTimeRanges_, &numberOfTimeRanges))) return ret; - Assert(numberOfTimeRanges == 1 || numberOfTimeRanges == 2); + ECCODES_ASSERT(numberOfTimeRanges == 1 || numberOfTimeRanges == 2); try { if (numberOfTimeRanges == 1) { diff --git a/src/accessor/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc index 725ace107..d61074776 100644 --- a/src/accessor/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -166,7 +166,7 @@ static int trial(const double* val, long v[6], long* basic_angle, long* sub_divi if (*sub_division < 0) return 0; - Assert(*sub_division >= 0); + ECCODES_ASSERT(*sub_division >= 0); return is_ok(val, v, *basic_angle, *sub_division); } diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index e5142532b..7564248eb 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -57,7 +57,7 @@ void grib_accessor_gen_t::init(const long len, grib_arguments* param) p = expression->evaluate_string(grib_handle_of_accessor(this), tmp, &s_len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to evaluate %s as string", name_); - Assert(0); + ECCODES_ASSERT(0); } s_len = strlen(p) + 1; pack_string(p, &s_len); @@ -542,12 +542,12 @@ int grib_accessor_gen_t::is_missing() "%s internal error (flags=0x%lX)", name_, flags_); - Assert(!"grib_accessor_gen_t::is_missing(): vvalue == NULL"); + ECCODES_ASSERT(!"grib_accessor_gen_t::is_missing(): vvalue == NULL"); return 0; } return vvalue_->missing; } - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); v = grib_handle_of_accessor(this)->buffer->data + offset_; diff --git a/src/accessor/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc index 48a93771c..876f797a4 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -110,7 +110,7 @@ int grib_accessor_global_gaussian_t::unpack_long(long* val, size_t* len) long* pl = NULL; /* pl array */ if ((ret = grib_get_size(h, pl_, &plsize)) != GRIB_SUCCESS) return ret; - Assert(plsize); + ECCODES_ASSERT(plsize); pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); grib_get_long_array_internal(h, pl_, pl, &plsize); @@ -199,13 +199,13 @@ int grib_accessor_global_gaussian_t::pack_long(const long* val, size_t* len) if ((ret = grib_get_size(h, pl_, &plsize)) != GRIB_SUCCESS) return ret; - Assert(plsize); + ECCODES_ASSERT(plsize); pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); grib_get_long_array_internal(h, pl_, pl, &plsize); max_pl = pl[0]; for (i = 1; i < plsize; i++) { - Assert(pl[i] > 0); + ECCODES_ASSERT(pl[i] > 0); if (pl[i] > max_pl) max_pl = pl[i]; } diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc index 556bec2e4..3181933fa 100644 --- a/src/accessor/grib_accessor_class_hash_array.cc +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -79,7 +79,7 @@ grib_hash_array_value* grib_accessor_hash_array_t::find_hash_value(int* err) *err = GRIB_SUCCESS; - Assert(ha != NULL); + ECCODES_ASSERT(ha != NULL); if (!key_) { grib_context_log(context_, GRIB_LOG_ERROR, "unable to get hash value for %s, set before getting", creator_->name); diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index 3d74576c5..48ab69eb0 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -22,7 +22,7 @@ void grib_accessor_ibmfloat_t::init(const long len, grib_arguments* arg) arg_ = arg; value_count(&count); length_ = 4 * count; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } template @@ -139,7 +139,7 @@ long grib_accessor_ibmfloat_t::byte_offset() void grib_accessor_ibmfloat_t::update_size(size_t s) { length_ = (long)s; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } long grib_accessor_ibmfloat_t::next_offset() diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index 31e7cd164..a3dc7a9c3 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -21,7 +21,7 @@ void grib_accessor_ieeefloat_t::init(const long len, grib_arguments* arg) arg_ = arg; value_count(&count); length_ = 4 * count; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } int grib_accessor_ieeefloat_t::value_count(long* len) @@ -121,7 +121,7 @@ int grib_accessor_ieeefloat_t::unpack_float(float* val, size_t* len) void grib_accessor_ieeefloat_t::update_size(size_t s) { length_ = (long)s; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } int grib_accessor_ieeefloat_t::nearest_smaller_value(double val, double* nearest) diff --git a/src/accessor/grib_accessor_class_ksec1expver.cc b/src/accessor/grib_accessor_class_ksec1expver.cc index bd981bc07..6d5edef81 100644 --- a/src/accessor/grib_accessor_class_ksec1expver.cc +++ b/src/accessor/grib_accessor_class_ksec1expver.cc @@ -17,7 +17,7 @@ void grib_accessor_ksec1expver_t::init(const long len, grib_arguments* arg) { grib_accessor_ascii_t::init(len, arg); length_ = len; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } int grib_accessor_ksec1expver_t::unpack_long(long* val, size_t* len) @@ -29,7 +29,7 @@ int grib_accessor_ksec1expver_t::unpack_long(long* val, size_t* len) char expver[5]; char refexpver[5]; size_t llen = length_ + 1; - Assert(length_ == 4); + ECCODES_ASSERT(length_ == 4); if (*len < 1) { grib_context_log(context_, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", name_, 1); diff --git a/src/accessor/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc index 3beed4bae..1655234cf 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -106,7 +106,7 @@ int grib_accessor_latlon_increment_t::unpack_double(double* val, size_t* len) *val = GRIB_MISSING_DOUBLE; } else { - Assert(angleDivisor != 0); + ECCODES_ASSERT(angleDivisor != 0); *val = (double)directionIncrement / angleDivisor * angleMultiplier; } diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index 0dc4e3641..a7a24c41a 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -57,7 +57,7 @@ int grib_accessor_local_definition_t::pack_long(const long* val, size_t* len) long editionNumber = 0; if (grib_get_long(hand, "editionNumber", &editionNumber) == GRIB_SUCCESS) { - Assert(editionNumber != 1); + ECCODES_ASSERT(editionNumber != 1); } if (grib_get_long(hand, productDefinitionTemplateNumber_, &productDefinitionTemplateNumber) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc index 1d746e185..e4a4e5c5f 100644 --- a/src/accessor/grib_accessor_class_long_vector.cc +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -28,7 +28,7 @@ void grib_accessor_long_vector_t::init(const long l, grib_arguments* c) index_ = c->get_long(grib_handle_of_accessor(this), n++); /* check index_ on init and never change it */ - Assert(index_ < v->number_of_elements_ && index_ >= 0); + ECCODES_ASSERT(index_ < v->number_of_elements_ && index_ >= 0); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc index 721a66fcf..9651ae75e 100644 --- a/src/accessor/grib_accessor_class_lookup.cc +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -97,7 +97,7 @@ int grib_accessor_lookup_t::unpack_long(long* val, size_t* len) /* This is used when reparsing or rebuilding */ if (h->loader) { - Assert(*len == 1); + ECCODES_ASSERT(*len == 1); return h->loader->lookup_long(h->context, h->loader, name_, val); } diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index 52ab4c201..f2a2fde59 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -32,7 +32,7 @@ void grib_accessor_md5_t::init(const long len, grib_arguments* arg) current = blocklist_; } else { - Assert(current); + ECCODES_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); diff --git a/src/accessor/grib_accessor_class_message.cc b/src/accessor/grib_accessor_class_message.cc index a8b7e1996..15115d65e 100644 --- a/src/accessor/grib_accessor_class_message.cc +++ b/src/accessor/grib_accessor_class_message.cc @@ -42,7 +42,7 @@ void grib_accessor_message_t::resize(size_t new_size) // grib_context_free(context_ , zero); // grib_context_log(context_ , GRIB_LOG_DEBUG, "resize: grib_accessor_message %ld %ld %s %s", // (long)new_size, (long)a->length, a->cclass->name, name_ ); - // Assert(new_size == length_ ); + // ECCODES_ASSERT(new_size == length_ ); } int grib_accessor_message_t::value_count(long* count) diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 4cdd5676d..e1997a4c3 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -155,7 +155,7 @@ int grib_accessor_number_of_points_gaussian_t::unpack_long_new(long* val, size_t return GRIB_GEOCALCULUS_PROBLEM; if (grib_get_long(h, "angleSubdivisions", &angleSubdivisions) == GRIB_SUCCESS) { - Assert(angleSubdivisions > 0); + ECCODES_ASSERT(angleSubdivisions > 0); angular_precision = 1.0 / angleSubdivisions; } @@ -264,7 +264,7 @@ int grib_accessor_number_of_points_gaussian_t::unpack_long_with_legacy_support(l return GRIB_GEOCALCULUS_PROBLEM; if (grib_get_long(h, "angleSubdivisions", &angleSubdivisions) == GRIB_SUCCESS) { - Assert(angleSubdivisions > 0); + ECCODES_ASSERT(angleSubdivisions > 0); angular_precision = 1.0 / angleSubdivisions; } diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc index 63a2ad963..fb975b1df 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -33,7 +33,7 @@ int grib_accessor_number_of_values_data_raw_packing_t::unpack_long(long* val, si long byte_count = 0; adata = grib_find_accessor(grib_handle_of_accessor(this), values_); - Assert(adata != NULL); + ECCODES_ASSERT(adata != NULL); byte_count = adata->byte_count(); if ((err = grib_get_long_internal(grib_handle_of_accessor(this), precision_, &precision)) != GRIB_SUCCESS) return err; diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index e3f9e2527..cf9cbe78e 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -98,7 +98,7 @@ int grib_accessor_octahedral_gaussian_t::unpack_long(long* val, size_t* len) if ((ret = grib_get_size(hand, pl_, &plsize)) != GRIB_SUCCESS) return ret; - Assert(plsize); /* pl array must have at least one element */ + ECCODES_ASSERT(plsize); /* pl array must have at least one element */ pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); if (!pl) { diff --git a/src/accessor/grib_accessor_class_padding.cc b/src/accessor/grib_accessor_class_padding.cc index e70c93147..1bb7d72d7 100644 --- a/src/accessor/grib_accessor_class_padding.cc +++ b/src/accessor/grib_accessor_class_padding.cc @@ -43,7 +43,7 @@ void grib_accessor_padding_t::resize(size_t new_size) grib_context_log(context_, GRIB_LOG_DEBUG, "grib_accessor_padding::resize new_size=%zu length_ =%ld %s %s", new_size, length_, class_name_, name_); - Assert(new_size == length_); + ECCODES_ASSERT(new_size == length_); } int grib_accessor_padding_t::value_count(long* c) diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index 5973f7ac1..55d800b06 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -213,7 +213,7 @@ int grib_accessor_proj_string_t::unpack_string(char* v, size_t* len) grib_handle* h = grib_handle_of_accessor(this); size_t size = sizeof(grid_type) / sizeof(*grid_type); - Assert(endpoint_ == ENDPOINT_SOURCE || endpoint_ == ENDPOINT_TARGET); + ECCODES_ASSERT(endpoint_ == ENDPOINT_SOURCE || endpoint_ == ENDPOINT_TARGET); size_t l = 100; // Safe bet if (*len < l) { @@ -247,7 +247,7 @@ int grib_accessor_proj_string_t::unpack_string(char* v, size_t* len) } size = strlen(v); - Assert(size > 0); + ECCODES_ASSERT(size > 0); *len = size + 1; return err; } diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc index b27a83b43..75e5c5983 100644 --- a/src/accessor/grib_accessor_class_raw.cc +++ b/src/accessor/grib_accessor_class_raw.cc @@ -37,7 +37,7 @@ void grib_accessor_raw_t::init(const long len, grib_arguments* arg) if (length_ < 0) length_ = 0; - /* Assert(length_ >=0); */ + /* ECCODES_ASSERT(length_ >=0); */ } long grib_accessor_raw_t::get_native_type() @@ -85,7 +85,7 @@ void grib_accessor_raw_t::update_size(size_t s) { grib_context_log(context_, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", name_, length_, s); length_ = s; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } void accessor_raw_set_length(grib_accessor* a, size_t len) diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc index 8b444f9c8..5eab67f0d 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.cc +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -40,7 +40,7 @@ int grib_accessor_reference_value_error_t::unpack_double(double* val, size_t* le else if (!strcmp(floatType_, "ieee")) *val = grib_ieeefloat_error(referenceValue); else - Assert(1 == 0); + ECCODES_ASSERT(1 == 0); if (ret == GRIB_SUCCESS) *len = 1; diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc index ceded90a1..0bc34985c 100644 --- a/src/accessor/grib_accessor_class_section.cc +++ b/src/accessor/grib_accessor_class_section.cc @@ -66,10 +66,10 @@ void grib_accessor_section_t::update_size(size_t length) { size_t size = 1; long len = length; - Assert(length <= 0x7fffffff); + ECCODES_ASSERT(length <= 0x7fffffff); if (sub_section_->aclength) { int e = sub_section_->aclength->pack_long(&len, &size); - Assert(e == GRIB_SUCCESS); + ECCODES_ASSERT(e == GRIB_SUCCESS); // printf("update_length %s %ld %ld\n", sub_section_ ->aclength->name, // (long)sub_section_ ->aclength->offset, // (long)sub_section_ ->aclength->length); @@ -80,7 +80,7 @@ void grib_accessor_section_t::update_size(size_t length) // printf("update_size %s %ld\n", a->name, length_ ); - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } grib_accessor* grib_accessor_section_t::next(grib_accessor* a, int explore) diff --git a/src/accessor/grib_accessor_class_section_length.cc b/src/accessor/grib_accessor_class_section_length.cc index f82247d1e..737a940f2 100644 --- a/src/accessor/grib_accessor_class_section_length.cc +++ b/src/accessor/grib_accessor_class_section_length.cc @@ -20,7 +20,7 @@ void grib_accessor_section_length_t::init(const long len, grib_arguments* arg) length_ = len; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } void grib_accessor_section_length_t::dump(eccodes::Dumper* dumper) diff --git a/src/accessor/grib_accessor_class_section_padding.cc b/src/accessor/grib_accessor_class_section_padding.cc index a1972fe55..73ccc2de0 100644 --- a/src/accessor/grib_accessor_class_section_padding.cc +++ b/src/accessor/grib_accessor_class_section_padding.cc @@ -45,7 +45,7 @@ size_t grib_accessor_section_padding_t::preferred_size(int from_handle) else alength = 0; - /*Assert(length_ >=0);*/ + /*ECCODES_ASSERT(length_ >=0);*/ if (alength < 0) alength = 0; diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc index 973e39e76..ee2b8e617 100644 --- a/src/accessor/grib_accessor_class_section_pointer.cc +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -22,7 +22,7 @@ void grib_accessor_section_pointer_t::init(const long len, grib_arguments* arg) sectionLength_ = arg->get_name(grib_handle_of_accessor(this), n++); sectionNumber_ = arg->get_long(grib_handle_of_accessor(this), n++); - Assert(sectionNumber_ < MAX_NUM_SECTIONS); + ECCODES_ASSERT(sectionNumber_ < MAX_NUM_SECTIONS); grib_handle_of_accessor(this)->section_offset[sectionNumber_] = (char*)sectionOffset_; grib_handle_of_accessor(this)->section_length[sectionNumber_] = (char*)sectionLength_; diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index 697e93e32..c2f7a8d9f 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -24,7 +24,7 @@ void grib_accessor_signed_t::init(const long len, grib_arguments* arg) value_count(&count); length_ = len * count; nbytes_ = len; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } void grib_accessor_signed_t::dump(eccodes::Dumper* dumper) @@ -67,7 +67,7 @@ int grib_accessor_signed_t::unpack_long(long* val, size_t* len) } if (flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(nbytes_ <= 4); + ECCODES_ASSERT(nbytes_ <= 4); missing = ones[nbytes_]; } @@ -106,7 +106,7 @@ int grib_accessor_signed_t::pack_long(const long* val, size_t* len) } if (flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(nbytes_ <= 4); + ECCODES_ASSERT(nbytes_ <= 4); missing = ones[nbytes_]; } @@ -184,7 +184,7 @@ long grib_accessor_signed_t::byte_offset() void grib_accessor_signed_t::update_size(size_t s) { length_ = s; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } long grib_accessor_signed_t::next_offset() @@ -199,7 +199,7 @@ int grib_accessor_signed_t::is_missing() const grib_handle* hand = grib_handle_of_accessor(this); if (length_ == 0) { - Assert(vvalue_ != NULL); + ECCODES_ASSERT(vvalue_ != NULL); return vvalue_->missing; } diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc index efd903177..f405ac3b4 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.cc +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -55,7 +55,7 @@ int grib_accessor_simple_packing_error_t::unpack_double(double* val, size_t* len else if (!strcmp(floatType_, "ieee")) *val = grib_ieeefloat_error(referenceValue); else - Assert(1 == 0); + ECCODES_ASSERT(1 == 0); if (bitsPerValue != 0) *val = (*val + codes_power(binaryScaleFactor, 2)) * codes_power(-decimalScaleFactor, 10) * 0.5; diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index 98240e562..33f3280c4 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -173,7 +173,7 @@ static int grib_load_smart_table(grib_context* c, const char* filename, if (!f) return GRIB_IO_PROBLEM; - Assert(t != NULL); + ECCODES_ASSERT(t != NULL); if (t->filename[0] == NULL) { t->filename[0] = grib_context_strdup_persistent(c, filename); diff --git a/src/accessor/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc index 7b18ac3c2..6369fe1b7 100644 --- a/src/accessor/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -48,7 +48,7 @@ int grib_accessor_sprintf_t::unpack_string(char* val, size_t* len) char *theEnd = NULL, *start; start = (char*)&(uname[++i]); precision = strtol(start, &theEnd, 10); - Assert(*theEnd != 0); + ECCODES_ASSERT(*theEnd != 0); while (uname[i] != *theEnd) i++; } diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index a822cb595..2d301e8ba 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -97,7 +97,7 @@ int grib_accessor_unexpanded_descriptors_t::pack_long(const long* val, size_t* l return ret; expanded = dynamic_cast(grib_find_accessor(hand, "expandedCodes")); - Assert(expanded != NULL); + ECCODES_ASSERT(expanded != NULL); ret = expanded->grib_accessor_expanded_descriptors_set_do_expand(1); if (ret != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index 1b13d80eb..be4f8341a 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -78,7 +78,7 @@ int grib_accessor_unsigned_t::pack_long_unsigned_helper(const long* val, size_t* return err; if (flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(nbytes_ <= 4); + ECCODES_ASSERT(nbytes_ <= 4); missing = ones[nbytes_]; } @@ -185,7 +185,7 @@ int grib_accessor_unsigned_t::unpack_long(long* val, size_t* len) } if (flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(nbytes_ <= 4); + ECCODES_ASSERT(nbytes_ <= 4); missing = ones[nbytes_]; } @@ -242,7 +242,7 @@ int grib_accessor_unsigned_t::is_missing() const grib_handle* hand = grib_handle_of_accessor(this); if (length_ == 0) { - Assert(vvalue_ != NULL); + ECCODES_ASSERT(vvalue_ != NULL); return vvalue_->missing; } diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index c52484c64..a746041ec 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -37,7 +37,7 @@ long grib_accessor_values_t::init_length() /* When reparsing */ if (offsetdata < offsetsection) { /* printf("init_length offsetdata < offsetsection=0\n"); */ - Assert(grib_handle_of_accessor(this)->loader); + ECCODES_ASSERT(grib_handle_of_accessor(this)->loader); return 0; } @@ -55,7 +55,7 @@ void grib_accessor_values_t::init(const long v, grib_arguments* params) values_dirty_ = 1; length_ = init_length(); - /* Assert(length_ >=0); */ + /* ECCODES_ASSERT(length_ >=0); */ } long grib_accessor_values_t::get_native_type() @@ -88,7 +88,7 @@ void grib_accessor_values_t::update_size(size_t s) { grib_context_log(context_, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", name_, length_, s); length_ = s; - Assert(length_ >= 0); + ECCODES_ASSERT(length_ >= 0); } int grib_accessor_values_t::compare(grib_accessor* b) diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index 6ee016599..ea3924a65 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -34,11 +34,11 @@ int grib_accessor_vector_t::unpack_double(double* val, size_t* len) grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(this), vector_); grib_accessor_abstract_vector_t* v = (grib_accessor_abstract_vector_t*)va; - Assert(index_ >= 0); + ECCODES_ASSERT(index_ >= 0); if (index_ >= v->number_of_elements_) { grib_context_log(context_, GRIB_LOG_FATAL, "index=%d number_of_elements=%d for %s", index_, v->number_of_elements_, name_); - Assert(index_ < v->number_of_elements_); + ECCODES_ASSERT(index_ < v->number_of_elements_); } if (va->dirty_) { diff --git a/src/action.cc b/src/action.cc index a5496c32d..ed7f3950f 100644 --- a/src/action.cc +++ b/src/action.cc @@ -72,7 +72,7 @@ static void init(grib_action_class* c) // if(c->super) { // grib_action_class *g = *(c->super); // if (g && !g->inited) { -// Assert(g->super == NULL); +// ECCODES_ASSERT(g->super == NULL); // g->init_class(g); // g->inited = 1; // } @@ -205,10 +205,10 @@ void grib_dump_action_branch(FILE* out, grib_action* a, int decay) void grib_dump_action_tree(grib_context* ctx, FILE* out) { - Assert(ctx); - Assert(ctx->grib_reader); - Assert(ctx->grib_reader->first); - Assert(out); + ECCODES_ASSERT(ctx); + ECCODES_ASSERT(ctx->grib_reader); + ECCODES_ASSERT(ctx->grib_reader->first); + ECCODES_ASSERT(out); // grib_dump_action_branch(out, ctx->grib_reader->first->root, 0); // grib_action* next = ctx->grib_reader->first->root; diff --git a/src/action_class_concept.cc b/src/action_class_concept.cc index 598a4cd60..649a98dd6 100644 --- a/src/action_class_concept.cc +++ b/src/action_class_concept.cc @@ -230,12 +230,12 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept* if (self->concept_value != NULL) return self->concept_value; - Assert(self->masterDir); + ECCODES_ASSERT(self->masterDir); grib_get_string(h, self->masterDir, masterDir, &lenMasterDir); // See ECC-1920: The basename could be a key or a string char* basename = self->basename; // default is a string - Assert(basename); + ECCODES_ASSERT(basename); char baseNameValue[1024] = {0,}; // its value if a key size_t lenBaseName = sizeof(baseNameValue); if (grib_get_string(h, self->basename, baseNameValue, &lenBaseName) == GRIB_SUCCESS) { @@ -399,7 +399,7 @@ int get_concept_condition_string(grib_handle* h, const char* key, const char* va while (concept_condition) { //grib_expression* expression = concept_condition->expression; const char* condition_name = concept_condition->name; - //Assert(expression); + //ECCODES_ASSERT(expression); if (concept_condition_expression_true(h, concept_condition, exprVal) && strcmp(condition_name, "one") != 0) { length += snprintf(result + length, 2048, "%s%s=%s", (length == 0 ? "" : ","), condition_name, exprVal); diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index 660931b9f..4f2d44c28 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -100,7 +100,7 @@ grib_action* grib_action_create_gen(grib_context* context, const char* name, con flag_stringtype = 1; if (flag_lowercase && !flag_stringtype) { printf("grib_action_create_gen name=%s. Has lowercase but not string_type\n", name); - Assert(0); + ECCODES_ASSERT(0); } } #endif diff --git a/src/action_class_hash_array.cc b/src/action_class_hash_array.cc index 55e87ddda..badb007af 100644 --- a/src/action_class_hash_array.cc +++ b/src/action_class_hash_array.cc @@ -195,7 +195,7 @@ static void destroy(grib_context* context, grib_action* act) // This is currently unset. So assert that it is NULL const grib_hash_array_value* v = self->hash_array; - Assert(v == NULL); + ECCODES_ASSERT(v == NULL); // if (v) // grib_trie_delete(v->index); // while (v) { @@ -233,7 +233,7 @@ static grib_hash_array_value* get_hash_array_impl(grib_handle* h, grib_action* a if (self->hash_array != NULL) return self->hash_array; - Assert(self->masterDir); + ECCODES_ASSERT(self->masterDir); grib_get_string(h, self->masterDir, masterDir, &lenMasterDir); snprintf(buf, 4096, "%s/%s", masterDir, self->basename); diff --git a/src/action_class_section.cc b/src/action_class_section.cc index 35d1e1bf5..add6c458e 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -69,10 +69,10 @@ static void init_class(grib_action_class* c) // static void check_sections(grib_section *s,grib_handle* h) // { // grib_accessor *a = s?s->block->first:NULL; -// if(s) Assert(s->h == h); +// if(s) ECCODES_ASSERT(s->h == h); // while(a) // { -// Assert(grib_handle_of_accessor(a) == h); +// ECCODES_ASSERT(grib_handle_of_accessor(a) == h); // check_sections(a->sub_section_,h); // a = a->next; // } @@ -107,7 +107,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, old_section = notified->sub_section_; if (!old_section) return GRIB_INTERNAL_ERROR; - Assert(old_section->h == h); + ECCODES_ASSERT(old_section->h == h); /* printf("old = %p\n",(void*)old_section->branch); */ /* printf("new = %p\n",(void*)la); */ @@ -139,7 +139,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, return GRIB_OUT_OF_MEMORY; tmp_handle->buffer = grib_create_growable_buffer(h->context); - Assert(tmp_handle->buffer); /* FIXME */ + ECCODES_ASSERT(tmp_handle->buffer); /* FIXME */ loader.data = h; loader.lookup_long = grib_lookup_long_from_handle; @@ -150,7 +150,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, return GRIB_INTERNAL_ERROR; } - Assert(h->kid == NULL); + ECCODES_ASSERT(h->kid == NULL); tmp_handle->loader = &loader; tmp_handle->main = h; h->kid = tmp_handle; @@ -188,16 +188,16 @@ static int notify_change(grib_action* act, grib_accessor* notified, //if(h->context->debug > 10) // grib_dump_content(tmp_handle,stdout,NULL,0,NULL); - /* Assert(tmp_handle->buffer->ulength == len); */ + /* ECCODES_ASSERT(tmp_handle->buffer->ulength == len); */ /* grib_empty_section(h->context,old_section); */ grib_buffer_replace(notified, tmp_handle->buffer->data, tmp_handle->buffer->ulength, 0, 1); - Assert(tmp_handle->root->block->first != NULL); + ECCODES_ASSERT(tmp_handle->root->block->first != NULL); grib_swap_sections(old_section, tmp_handle->root->block->first->sub_section_); - Assert(tmp_handle->dependencies == NULL); + ECCODES_ASSERT(tmp_handle->dependencies == NULL); /* printf("grib_handle_delete %p\n",(void*)tmp_handle); */ grib_handle_delete(tmp_handle); @@ -218,7 +218,7 @@ static int notify_change(grib_action* act, grib_accessor* notified, if (h->context->debug > 10) grib_dump_content(h, stdout, "debug", ~0, NULL); - Assert(size == len); + ECCODES_ASSERT(size == len); grib_update_paddings(old_section); diff --git a/src/action_class_switch.cc b/src/action_class_switch.cc index d792d7cac..ba0649c35 100644 --- a/src/action_class_switch.cc +++ b/src/action_class_switch.cc @@ -139,7 +139,7 @@ static int execute(grib_action* act, grib_handle* h) size_t size = sizeof(tmp); int err = 0; - Assert(args); + ECCODES_ASSERT(args); while (c) { e = args->expression_; diff --git a/src/action_class_write.cc b/src/action_class_write.cc index 01d5d8a54..109268cc6 100644 --- a/src/action_class_write.cc +++ b/src/action_class_write.cc @@ -126,7 +126,7 @@ static int execute(grib_action* act, grib_handle* h) } } - Assert(filename); + ECCODES_ASSERT(filename); if (a->append) of = grib_file_open(filename, "a", &err); else diff --git a/src/bufr_util.cc b/src/bufr_util.cc index 8ac3da975..5865bac64 100644 --- a/src/bufr_util.cc +++ b/src/bufr_util.cc @@ -809,7 +809,7 @@ static char* codes_bufr_header_get_centre_name(long edition, long centre_code) if( *p =='\0' ) continue; - Assert(isdigit(*p)); + ECCODES_ASSERT(isdigit(*p)); while(*p != '\0') { if(isspace(*p)) break; code *= 10; @@ -838,13 +838,13 @@ int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* v { static const char* NOT_FOUND = "not_found"; bool isEcmwfLocal = false; - Assert(bh); - Assert(key); + ECCODES_ASSERT(bh); + ECCODES_ASSERT(key); *len = strlen(NOT_FOUND); // By default isEcmwfLocal = (bh->ecmwfLocalSectionPresent == 1); - Assert(!(isEcmwfLocal && bh->bufrHeaderCentre != 98)); - Assert(!(bh->ecmwfLocalSectionPresent && !bh->localSectionPresent)); + ECCODES_ASSERT(!(isEcmwfLocal && bh->bufrHeaderCentre != 98)); + ECCODES_ASSERT(!(bh->ecmwfLocalSectionPresent && !bh->localSectionPresent)); if (strcmp(key, "message_offset") == 0) *len = snprintf(val, 32, "%lu", bh->message_offset); diff --git a/src/codes_util.cc b/src/codes_util.cc index 0175ecb2f..8ae1e7b15 100644 --- a/src/codes_util.cc +++ b/src/codes_util.cc @@ -33,7 +33,7 @@ double rint(double x) double result = 0; buf = (char*)malloc(_CVTBUFSIZE); err = _fcvt_s(buf, _CVTBUFSIZE, x, 0, &decimal, &sign); - Assert(err == 0); + ECCODES_ASSERT(err == 0); result = atof(buf); if (sign == 1) { result = result * -1; @@ -148,7 +148,7 @@ int codes_flush_sync_close_file(FILE* f) int err = 0; int fd = 0; const grib_context* c = grib_context_get_default(); - Assert(f); + ECCODES_ASSERT(f); fd = fileno(f); if (fd == -1) { @@ -274,7 +274,7 @@ long convert_to_minutes(long step, long stepUnits) return step * 60; /* unit=hours */ if (stepUnits == 13) return step / 60; /* unit=seconds */ - /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ + /* ECCODES_ASSERT( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ result = step * u2m[stepUnits]; return (long)result; @@ -514,7 +514,7 @@ int codes_is_feature_enabled(const char* feature) int codes_get_features(char* result, size_t* length, int select) { - Assert(select == CODES_FEATURES_ALL || select == CODES_FEATURES_ENABLED || select == CODES_FEATURES_DISABLED); + ECCODES_ASSERT(select == CODES_FEATURES_ALL || select == CODES_FEATURES_ENABLED || select == CODES_FEATURES_DISABLED); const size_t num = NUMBER(known_features); result[0] = '\0'; @@ -541,7 +541,7 @@ int codes_get_features(char* result, size_t* length, int select) if (result[actual_length - 1] == ' ') result[actual_length - 1] = '\0'; - Assert(*length >= actual_length); + ECCODES_ASSERT(*length >= actual_length); *length = actual_length; return GRIB_SUCCESS; } diff --git a/src/dumper/grib_dumper_class_bufr_decode_C.cc b/src/dumper/grib_dumper_class_bufr_decode_C.cc index eddec8382..e70e3123b 100644 --- a/src/dumper/grib_dumper_class_bufr_decode_C.cc +++ b/src/dumper/grib_dumper_class_bufr_decode_C.cc @@ -579,7 +579,7 @@ void BufrDecodeC::dump_attributes(grib_accessor* a, const char* prefix) void BufrDecodeC::header(const grib_handle* h) { - Assert(h->product_kind == PRODUCT_BUFR); + ECCODES_ASSERT(h->product_kind == PRODUCT_BUFR); if (count_ < 2) { /* This is the first message being processed */ diff --git a/src/dumper/grib_dumper_class_bufr_encode_C.cc b/src/dumper/grib_dumper_class_bufr_encode_C.cc index 3aef72260..ff2e261dc 100644 --- a/src/dumper/grib_dumper_class_bufr_encode_C.cc +++ b/src/dumper/grib_dumper_class_bufr_encode_C.cc @@ -92,7 +92,7 @@ void BufrEncodeC::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -186,7 +186,7 @@ void BufrEncodeC::dump_values_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -300,7 +300,7 @@ void BufrEncodeC::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -406,7 +406,7 @@ void BufrEncodeC::dump_long_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -757,7 +757,7 @@ void BufrEncodeC::header(const grib_handle* h) char sampleName[200] = { 0 }; long localSectionPresent, edition, bufrHeaderCentre, isSatellite; - Assert(h->product_kind == PRODUCT_BUFR); + ECCODES_ASSERT(h->product_kind == PRODUCT_BUFR); grib_get_long(h, "localSectionPresent", &localSectionPresent); grib_get_long(h, "bufrHeaderCentre", &bufrHeaderCentre); diff --git a/src/dumper/grib_dumper_class_bufr_encode_filter.cc b/src/dumper/grib_dumper_class_bufr_encode_filter.cc index 201fb537e..3229e8383 100644 --- a/src/dumper/grib_dumper_class_bufr_encode_filter.cc +++ b/src/dumper/grib_dumper_class_bufr_encode_filter.cc @@ -69,7 +69,7 @@ void BufrEncodeFilter::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); begin_ = 0; empty_ = 0; @@ -158,7 +158,7 @@ void BufrEncodeFilter::dump_values_attribute(grib_accessor* a, const char* prefi else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -251,7 +251,7 @@ void BufrEncodeFilter::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); begin_ = 0; empty_ = 0; @@ -338,7 +338,7 @@ void BufrEncodeFilter::dump_long_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -689,7 +689,7 @@ void BufrEncodeFilter::header(const grib_handle* h) char sampleName[128] = { 0 }; long localSectionPresent, edition, bufrHeaderCentre, isSatellite; - Assert(h->product_kind == PRODUCT_BUFR); + ECCODES_ASSERT(h->product_kind == PRODUCT_BUFR); grib_get_long(h, "localSectionPresent", &localSectionPresent); grib_get_long(h, "bufrHeaderCentre", &bufrHeaderCentre); diff --git a/src/dumper/grib_dumper_class_bufr_encode_fortran.cc b/src/dumper/grib_dumper_class_bufr_encode_fortran.cc index 1e3a6e9b6..2c697d0bf 100644 --- a/src/dumper/grib_dumper_class_bufr_encode_fortran.cc +++ b/src/dumper/grib_dumper_class_bufr_encode_fortran.cc @@ -139,7 +139,7 @@ void BufrEncodeFortran::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -232,7 +232,7 @@ void BufrEncodeFortran::dump_values_attribute(grib_accessor* a, const char* pref else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -346,7 +346,7 @@ void BufrEncodeFortran::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -451,7 +451,7 @@ void BufrEncodeFortran::dump_long_attribute(grib_accessor* a, const char* prefix else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; diff --git a/src/dumper/grib_dumper_class_bufr_encode_python.cc b/src/dumper/grib_dumper_class_bufr_encode_python.cc index 9c50d6ce4..0f91a1c50 100644 --- a/src/dumper/grib_dumper_class_bufr_encode_python.cc +++ b/src/dumper/grib_dumper_class_bufr_encode_python.cc @@ -90,7 +90,7 @@ void BufrEncodePython::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -183,7 +183,7 @@ void BufrEncodePython::dump_values_attribute(grib_accessor* a, const char* prefi else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -297,7 +297,7 @@ void BufrEncodePython::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -401,7 +401,7 @@ void BufrEncodePython::dump_long_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; diff --git a/src/dumper/grib_dumper_class_bufr_simple.cc b/src/dumper/grib_dumper_class_bufr_simple.cc index 84b7a0cbc..0dc8ca2bd 100644 --- a/src/dumper/grib_dumper_class_bufr_simple.cc +++ b/src/dumper/grib_dumper_class_bufr_simple.cc @@ -71,7 +71,7 @@ void BufrSimple::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -160,7 +160,7 @@ void BufrSimple::dump_values_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -263,7 +263,7 @@ void BufrSimple::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -359,7 +359,7 @@ void BufrSimple::dump_long_attribute(grib_accessor* a, const char* prefix) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); empty_ = 0; @@ -553,7 +553,7 @@ void BufrSimple::dump_string(grib_accessor* a, const char* comment) fprintf(out_, " *** ERR=%d (%s) [dump_string on '%s']", err, grib_get_error_message(err), acc_name); return; } - Assert(size < MAX_STRING_SIZE); + ECCODES_ASSERT(size < MAX_STRING_SIZE); p = value; r = compute_bufr_key_rank(h, keys_, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -643,7 +643,7 @@ void BufrSimple::dump_section(grib_accessor* a, grib_block_of_accessors* block) empty_ = 1; err = grib_get_long(h, "numberOfSubsets", &(numberOfSubsets_)); - Assert(!err); + ECCODES_ASSERT(!err); _dump_long_array(h, out_, "dataPresentIndicator"); _dump_long_array(h, out_, "delayedDescriptorReplicationFactor"); _dump_long_array(h, out_, "shortDelayedDescriptorReplicationFactor"); diff --git a/src/dumper/grib_dumper_class_default.cc b/src/dumper/grib_dumper_class_default.cc index bfe2dae3d..dbbe6c763 100644 --- a/src/dumper/grib_dumper_class_default.cc +++ b/src/dumper/grib_dumper_class_default.cc @@ -83,7 +83,7 @@ void Default::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); aliases(a); if (comment) { @@ -549,7 +549,7 @@ void Default::dump_section(grib_accessor* a, grib_block_of_accessors* block) /* char tmp[512]; */ /* grib_section* s = a->sub_section; */ upper = (char*)malloc(strlen(a->name_) + 1); - Assert(upper); + ECCODES_ASSERT(upper); p = (char*)a->name_; q = upper; while (*p != '\0') { diff --git a/src/dumper/grib_dumper_class_grib_encode_C.cc b/src/dumper/grib_dumper_class_grib_encode_C.cc index 60378508b..baa489a51 100644 --- a/src/dumper/grib_dumper_class_grib_encode_C.cc +++ b/src/dumper/grib_dumper_class_grib_encode_C.cc @@ -307,7 +307,7 @@ void GribEncodeC::header(const grib_handle* h) ret = grib_get_long(h, "editionNumber", &edition); if (ret != GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to get edition number."); - Assert(0); + ECCODES_ASSERT(0); } fprintf(out_, diff --git a/src/dumper/grib_dumper_class_json.cc b/src/dumper/grib_dumper_class_json.cc index 8da2b74d5..901465eba 100644 --- a/src/dumper/grib_dumper_class_json.cc +++ b/src/dumper/grib_dumper_class_json.cc @@ -60,7 +60,7 @@ void Json::dump_values(grib_accessor* a) else { err = a->unpack_double(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); (void)err; /* TODO */ if (begin_ == 0 && empty_ == 0 && isAttribute_ == 0) @@ -152,7 +152,7 @@ void Json::dump_long(grib_accessor* a, const char* comment) else { err = a->unpack_long(&value, &size2); } - Assert(size2 == size); + ECCODES_ASSERT(size2 == size); if (begin_ == 0 && empty_ == 0 && isAttribute_ == 0) fprintf(out_, ","); @@ -398,7 +398,7 @@ void Json::dump_string(grib_accessor* a, const char* comment) err, grib_get_error_message(err), a->name_); } else { - Assert(size < MAX_STRING_SIZE); + ECCODES_ASSERT(size < MAX_STRING_SIZE); } p = value; if (grib_is_missing_string(a, (unsigned char*)value, size)) { diff --git a/src/dumper/grib_dumper_class_serialize.cc b/src/dumper/grib_dumper_class_serialize.cc index 1df154812..ef95eb453 100644 --- a/src/dumper/grib_dumper_class_serialize.cc +++ b/src/dumper/grib_dumper_class_serialize.cc @@ -274,7 +274,7 @@ void Serialize::dump_values(grib_accessor* a) if (len > 0) { columns_str = (char*)malloc((len + 1) * sizeof(char)); - Assert(columns_str); + ECCODES_ASSERT(columns_str); columns_str = (char*)memcpy(columns_str, pcf, len); columns_str[len] = '\0'; columns = atoi(columns_str); diff --git a/src/dumper/grib_dumper_class_wmo.cc b/src/dumper/grib_dumper_class_wmo.cc index d2d46d308..175ffd0e5 100644 --- a/src/dumper/grib_dumper_class_wmo.cc +++ b/src/dumper/grib_dumper_class_wmo.cc @@ -460,7 +460,7 @@ void Wmo::dump_section(grib_accessor* a, grib_block_of_accessors* block) if (is_wmo_section) { upper = (char*)malloc(strlen(a->name_) + 1); - Assert(upper); + ECCODES_ASSERT(upper); p = (char*)a->name_; q = upper; while (*p != '\0') { diff --git a/src/expression/grib_expression_class_accessor.cc b/src/expression/grib_expression_class_accessor.cc index 4dbab030b..c54ec9d1b 100644 --- a/src/expression/grib_expression_class_accessor.cc +++ b/src/expression/grib_expression_class_accessor.cc @@ -36,7 +36,7 @@ Accessor::string Accessor::evaluate_string(grib_handle* h, char* buf, size_t* si return NULL; } - Assert(buf); + ECCODES_ASSERT(buf); if ((*err = grib_get_string_internal(h, name_, mybuf, size)) != GRIB_SUCCESS) return NULL; @@ -90,7 +90,7 @@ void Accessor::add_dependency(grib_accessor* observer) if (!observed) { /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ - /* Assert(observed); */ + /* ECCODES_ASSERT(observed); */ return; } diff --git a/src/expression/grib_expression_class_is_in_dict.cc b/src/expression/grib_expression_class_is_in_dict.cc index f62ea7f84..dec212276 100644 --- a/src/expression/grib_expression_class_is_in_dict.cc +++ b/src/expression/grib_expression_class_is_in_dict.cc @@ -161,7 +161,7 @@ void IsInDict::add_dependency(grib_accessor* observer) if (!observed) { /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ - /* Assert(observed); */ + /* ECCODES_ASSERT(observed); */ return; } diff --git a/src/expression/grib_expression_class_is_in_list.cc b/src/expression/grib_expression_class_is_in_list.cc index 63ee22ecc..82c08cece 100644 --- a/src/expression/grib_expression_class_is_in_list.cc +++ b/src/expression/grib_expression_class_is_in_list.cc @@ -148,7 +148,7 @@ void IsInList::add_dependency(grib_accessor* observer) if (!observed) { /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ - /* Assert(observed); */ + /* ECCODES_ASSERT(observed); */ return; } diff --git a/src/expression/grib_expression_class_is_integer.cc b/src/expression/grib_expression_class_is_integer.cc index 7dcd48be3..271eb7bb7 100644 --- a/src/expression/grib_expression_class_is_integer.cc +++ b/src/expression/grib_expression_class_is_integer.cc @@ -95,7 +95,7 @@ void IsInteger::add_dependency(grib_accessor* observer) if (!observed) { /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ - /* Assert(observed); */ + /* ECCODES_ASSERT(observed); */ return; } diff --git a/src/expression/grib_expression_class_length.cc b/src/expression/grib_expression_class_length.cc index 1ac617a11..10e2a2ef0 100644 --- a/src/expression/grib_expression_class_length.cc +++ b/src/expression/grib_expression_class_length.cc @@ -44,7 +44,7 @@ int Length::evaluate_double(grib_handle* h, double* result) const Expression::string Length::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const { char mybuf[1024] = {0,}; - Assert(buf); + ECCODES_ASSERT(buf); if ((*err = grib_get_string_internal(h, name_, mybuf, size)) != GRIB_SUCCESS) return NULL; @@ -75,7 +75,7 @@ void Length::add_dependency(grib_accessor* observer) if (!observed) { /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ - /* Assert(observed); */ + /* ECCODES_ASSERT(observed); */ return; } diff --git a/src/functions.cc b/src/functions.cc index 6c6bba770..97c23b287 100644 --- a/src/functions.cc +++ b/src/functions.cc @@ -153,7 +153,7 @@ double grib_op_le_d(double a, double b) // LOOKUP(grib_op_mul); // LOOKUP(grib_op_modulo); // fprintf(stderr, "Cannot find grib_binop_long_proc\n"); -// Assert(0); +// ECCODES_ASSERT(0); // return NULL; // } @@ -172,7 +172,7 @@ double grib_op_le_d(double a, double b) // LOOKUP(grib_op_ge_d); // LOOKUP(grib_op_le_d); // fprintf(stderr, "Cannot find grib_binop_double_proc_name\n"); -// Assert(0); +// ECCODES_ASSERT(0); // return NULL; // } @@ -183,7 +183,7 @@ double grib_op_le_d(double a, double b) // LOOKUP(grib_op_not); // LOOKUP(grib_op_neg); // fprintf(stderr, "Cannot find grib_unop_long_proc_name\n"); -// Assert(0); +// ECCODES_ASSERT(0); // return NULL; // } @@ -193,6 +193,6 @@ double grib_op_le_d(double a, double b) // return "NULL"; // LOOKUP(grib_op_neg_d); // fprintf(stderr, "Cannot find grib_unop_double_proc_name\n"); -// Assert(0); +// ECCODES_ASSERT(0); // return NULL; // } diff --git a/src/geo/GeoIterator.cc b/src/geo/GeoIterator.cc index e77b8dc4a..e15d53406 100644 --- a/src/geo/GeoIterator.cc +++ b/src/geo/GeoIterator.cc @@ -26,17 +26,17 @@ GeoIterator::GeoIterator(grib_handle* h, unsigned long flags) : h_ = h; class_name_ = "geo_iterator"; flags_ = flags; - Assert(h_ != nullptr); + ECCODES_ASSERT(h_ != nullptr); CODES_CHECK(codes_get_size(h_, "values", &nv_), ""); - Assert(nv_ > 0); + ECCODES_ASSERT(nv_ > 0); data_ = (flags_ & GRIB_GEOITERATOR_NO_VALUES) ? nullptr : static_cast(grib_context_malloc(h_->context, nv_ * sizeof(double))); - Assert(data_ != nullptr); + ECCODES_ASSERT(data_ != nullptr); auto size = nv_; CODES_CHECK(codes_get_double_array(h_, "values", data_, &size), ""); - Assert(nv_ == size); + ECCODES_ASSERT(nv_ == size); } diff --git a/src/geo/grib_gaussian_reduced.cc b/src/geo/grib_gaussian_reduced.cc index 8ba2ed088..5e95e536e 100644 --- a/src/geo/grib_gaussian_reduced.cc +++ b/src/geo/grib_gaussian_reduced.cc @@ -59,7 +59,7 @@ static Fraction_type fraction_construct(Fraction_value_type top, Fraction_value_ */ Fraction_value_type g; Fraction_value_type sign = 1; - Assert(bottom != 0); + ECCODES_ASSERT(bottom != 0); if (top < 0) { top = -top; sign = -sign; @@ -91,8 +91,8 @@ static Fraction_type fraction_construct_from_double(double x) Fraction_value_type t2, top, bottom, g; size_t cnt = 0; - /*Assert(x != NAN);*/ - Assert(fabs(x) < 1e30); + /*ECCODES_ASSERT(x != NAN);*/ + ECCODES_ASSERT(fabs(x) < 1e30); if (x < 0) { sign = -sign; @@ -146,7 +146,7 @@ static Fraction_type fraction_construct_from_double(double x) static Fraction_value_type fraction_integralPart(const Fraction_type frac) { - Assert(frac.bottom_); + ECCODES_ASSERT(frac.bottom_); if (frac.bottom_ == 0) return frac.top_; return frac.top_ / frac.bottom_; } @@ -282,7 +282,7 @@ static void gaussian_reduced_row( Nw = fraction_integralPart(fraction_operator_divide(w, inc)); Nw_inc = fraction_operator_multiply_n_Frac(Nw, inc); - Assert(Ni_globe > 1); + ECCODES_ASSERT(Ni_globe > 1); /*if (Nw * inc < w) {*/ if (fraction_operator_less_than(Nw_inc, w)) { Nw += 1; @@ -401,7 +401,7 @@ void grib_get_reduced_row_legacy(long pl, double lon_first, double lon_last, lon } } - /*Assert(*npoints==irange);*/ + /*ECCODES_ASSERT(*npoints==irange);*/ #if EFDEBUG printf("-- pl=%ld npoints=%ld range=%.10e ilon_first=%ld ilon_last=%ld irange=%ld\n", pl, *npoints, range, *ilon_first, *ilon_last, irange); diff --git a/src/geo/iterator/grib_iterator.cc b/src/geo/iterator/grib_iterator.cc index 329ad4fbf..9f0be23eb 100644 --- a/src/geo/iterator/grib_iterator.cc +++ b/src/geo/iterator/grib_iterator.cc @@ -20,8 +20,8 @@ #include "geo/GeoIterator.h" // eccodes macros conflict with eckit - #ifdef Assert - #undef Assert + #ifdef ECCODES_ASSERT + #undef ECCODES_ASSERT #endif #endif diff --git a/src/geo/iterator/grib_iterator_class_gaussian.cc b/src/geo/iterator/grib_iterator_class_gaussian.cc index 50618ed2a..8f58c2ce4 100644 --- a/src/geo/iterator/grib_iterator_class_gaussian.cc +++ b/src/geo/iterator/grib_iterator_class_gaussian.cc @@ -101,7 +101,7 @@ static void binary_search_gaussian_latitudes(const double array[], const unsigne unsigned long high = n; unsigned long mid; const int descending = (array[n] < array[0]); - Assert(descending); /* Gaussian latitudes should be in descending order */ + ECCODES_ASSERT(descending); /* Gaussian latitudes should be in descending order */ while (low <= high) { mid = (high + low) / 2; diff --git a/src/geo/iterator/grib_iterator_class_gaussian_reduced.cc b/src/geo/iterator/grib_iterator_class_gaussian_reduced.cc index a060d48f8..c7881a7f2 100644 --- a/src/geo/iterator/grib_iterator_class_gaussian_reduced.cc +++ b/src/geo/iterator/grib_iterator_class_gaussian_reduced.cc @@ -176,7 +176,7 @@ int GaussianReduced::iterate_reduced_gaussian_subarea(grib_handle* h, /* Find starting latitude */ binary_search(lats, numlats - 1, lat_first, &l); - Assert(l < numlats); + ECCODES_ASSERT(l < numlats); // for(il=0; il 0); + ECCODES_ASSERT(angleSubdivisions > 0); angular_precision = 1.0 / angleSubdivisions; } @@ -296,7 +296,7 @@ int GaussianReduced::init(grib_handle* h, grib_arguments* args) if ((ret = grib_get_size(h, spl, &plsize)) != GRIB_SUCCESS) return ret; - Assert(plsize); + ECCODES_ASSERT(plsize); pl = (long*)grib_context_malloc(c, sizeof(long) * plsize); if (!pl) return GRIB_OUT_OF_MEMORY; diff --git a/src/geo/iterator/grib_iterator_class_healpix.cc b/src/geo/iterator/grib_iterator_class_healpix.cc index b6dc2db57..2fd48a20d 100644 --- a/src/geo/iterator/grib_iterator_class_healpix.cc +++ b/src/geo/iterator/grib_iterator_class_healpix.cc @@ -53,7 +53,7 @@ struct CodecFijNest // static std::tuple nest_to_fij(int n, int k) // { - // Assert(0 <= n); + // ECCODES_ASSERT(0 <= n); // auto f = n >> (2 * k); // f = n / (Nside * Nside) // n &= (1 << (2 * k)) - 1; // n = n % (Nside * Nside) // auto i = nest_decode_bits(n); @@ -93,9 +93,9 @@ inline int pll(int f) size_t HEALPix_nj(size_t N, size_t i) { - Assert(0 < N); + ECCODES_ASSERT(0 < N); size_t ni = 4 * N - 1; - Assert(i < ni); + ECCODES_ASSERT(i < ni); return i < N ? 4 * (i + 1) : i < 3 * N ? 4 * N : HEALPix_nj(N, ni - 1 - i); } @@ -197,7 +197,7 @@ int Healpix::iterate_healpix(long N) int i = std::max(0, (r + p)) >> 1; int j = std::max(0, (r - p)) >> 1; - Assert(f < 12 && i < Nside && j < Nside); + ECCODES_ASSERT(f < 12 && i < Nside && j < Nside); return CodecFijNest::fij_to_nest(f, i, j, k); }; @@ -241,7 +241,7 @@ int Healpix::iterate_healpix(long N) for (size_t i = 0, j = 0; i < Ny; i++) { // Compute the longitudes at a given latitude for (double longitude : HEALPix_longitudes(N, i)) { - Assert(ring_to_nest.at(j) < Npix); + ECCODES_ASSERT(ring_to_nest.at(j) < Npix); lons_[ring_to_nest.at(j)] = longitude; lats_[ring_to_nest.at(j)] = latitudes[i]; ++j; diff --git a/src/geo/iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc b/src/geo/iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc index f00bc974f..e087280a2 100644 --- a/src/geo/iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc +++ b/src/geo/iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc @@ -190,7 +190,7 @@ int LambertAzimuthalEqualArea::init_oblate(grib_handle* h, xy_x /= Q__dd; xy_y *= Q__dd; rho = hypot(xy_x, xy_y); - Assert(rho >= EPS10); /* TODO(masn): check */ + ECCODES_ASSERT(rho >= EPS10); /* TODO(masn): check */ const double asin_arg = (0.5 * rho / Q__rq); if (asin_arg < -1.0 || asin_arg > 1.0) { grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid value: arcsin argument=%g", asin_arg); diff --git a/src/geo/iterator/grib_iterator_class_latlon.cc b/src/geo/iterator/grib_iterator_class_latlon.cc index 93d0acb8f..937d39e0f 100644 --- a/src/geo/iterator/grib_iterator_class_latlon.cc +++ b/src/geo/iterator/grib_iterator_class_latlon.cc @@ -114,7 +114,7 @@ int Latlon::init(grib_handle* h, grib_arguments* args) /* So try to compute the increment */ if ((grib_is_missing(h, s_jdir, &err) && err == GRIB_SUCCESS) || (jdir == GRIB_MISSING_DOUBLE)) { const long Nj = Nj_; - Assert(Nj > 1); + ECCODES_ASSERT(Nj > 1); if (lat1 > lat2) { jdir = (lat1 - lat2) / (Nj - 1); } diff --git a/src/geo/nearest/grib_nearest.cc b/src/geo/nearest/grib_nearest.cc index 81feae303..c2a97e059 100644 --- a/src/geo/nearest/grib_nearest.cc +++ b/src/geo/nearest/grib_nearest.cc @@ -146,8 +146,8 @@ int Nearest::grib_nearest_find_generic( /* First pass: collect all latitudes and longitudes */ while (grib_iterator_next(iter, &lat, &lon, &the_value)) { ++the_index; - Assert(ilat < *out_lats_count); - Assert(ilon < *out_lons_count); + ECCODES_ASSERT(ilat < *out_lats_count); + ECCODES_ASSERT(ilon < *out_lons_count); (*out_lats)[ilat++] = lat; (*out_lons)[ilon++] = lon; } @@ -157,7 +157,7 @@ int Nearest::grib_nearest_find_generic( grib_binary_search(*out_lats, *out_lats_count - 1, inlat, &idx_upper, &idx_lower); lat2 = (*out_lats)[idx_upper]; lat1 = (*out_lats)[idx_lower]; - Assert(lat1 <= lat2); + ECCODES_ASSERT(lat1 <= lat2); /* Second pass: Iterate again and collect candidate neighbours */ grib_iterator_reset(iter); @@ -194,7 +194,7 @@ int Nearest::grib_nearest_find_generic( /* Sanity check for sorting */ #ifdef DEBUG for (i = 0; i < nneighbours - 1; ++i) { - Assert(neighbours[i].m_dist <= neighbours[i + 1].m_dist); + ECCODES_ASSERT(neighbours[i].m_dist <= neighbours[i + 1].m_dist); } #endif @@ -342,7 +342,7 @@ int grib_nearest_find_multiple( if (is_lsm) { int noland = 1; /* ECC-499: In land-sea mask mode, 'values' cannot be NULL because we need to query whether >= 0.5 */ - Assert(values); + ECCODES_ASSERT(values); for (i = 0; i < npoints; i++) { ret = grib_nearest_find(nearest, h, inlats[i], inlons[i], flags, qoutlats, qoutlons, qvalues, qdistances, qindexes, &len); @@ -419,7 +419,7 @@ int grib_nearest_find( grib_handle* h = (grib_handle*)ch; if (!nearest) return GRIB_INVALID_ARGUMENT; - Assert(flags <= (GRIB_NEAREST_SAME_GRID | GRIB_NEAREST_SAME_DATA | GRIB_NEAREST_SAME_POINT)); + ECCODES_ASSERT(flags <= (GRIB_NEAREST_SAME_GRID | GRIB_NEAREST_SAME_DATA | GRIB_NEAREST_SAME_POINT)); int ret = nearest->nearest->find(h, inlat, inlon, flags, outlats, outlons, values, distances, indexes, len); if (ret != GRIB_SUCCESS) { diff --git a/src/geo/nearest/grib_nearest_class_regular.cc b/src/geo/nearest/grib_nearest_class_regular.cc index 1884b347d..d773ba23c 100644 --- a/src/geo/nearest/grib_nearest_class_regular.cc +++ b/src/geo/nearest/grib_nearest_class_regular.cc @@ -268,7 +268,7 @@ int Regular::find(grib_handle* h, *} */ /* Using the brute force approach described above */ - /* Assert(k_[kk] < nvalues); */ + /* ECCODES_ASSERT(k_[kk] < nvalues); */ /* values[kk]=nearest->values[k_[kk]]; */ if (k_[kk] >= INT_MAX) { diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc index 98d247ff4..6f4e28f18 100644 --- a/src/grib_accessor_class.cc +++ b/src/grib_accessor_class.cc @@ -247,7 +247,7 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l) if (a->same_ && (a->same_ == a)) { fprintf(stderr, "---> %s\n", a->name_); - Assert(a->same_ != a); + ECCODES_ASSERT(a->same_ != a); } } } @@ -304,7 +304,7 @@ int grib_section_adjust_sizes(grib_section* s, int update, int depth) size_t len = 1; long plen = 0; int lret = s->aclength->unpack_long(&plen, &len); - Assert(lret == GRIB_SUCCESS); + ECCODES_ASSERT(lret == GRIB_SUCCESS); /* This happens when there is some padding */ if ((plen != length) || force_update) { if (update) { @@ -373,7 +373,7 @@ int grib_get_block_length(grib_section* s, size_t* l) // if(s->h->context->debug) // printf("SECTION updating length %ld %s\n",plen,s->owner->name); // } -// // if(s->aclength) Assert(*l == plen); +// // if(s->aclength) ECCODES_ASSERT(*l == plen); // return GRIB_SUCCESS; } @@ -403,7 +403,7 @@ void grib_update_paddings(grib_section* s) /* while((changed = find_paddings(s)) != NULL) */ while ((changed = find_paddings(s->h->root)) != NULL) { - Assert(changed != last); + ECCODES_ASSERT(changed != last); changed->resize(changed->preferred_size(0)); last = changed; } diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index b9ae6baec..092ce83e9 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -656,10 +656,10 @@ static const struct accessor_class_hash* grib_accessor_hash (const char *str, si #ifdef DEBUG { const char *s; - Assert( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH ); - Assert( key <= MAX_HASH_VALUE ); + ECCODES_ASSERT( len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH ); + ECCODES_ASSERT( key <= MAX_HASH_VALUE ); s = classes[key].name; - Assert( *str == *s && strcmp(str + 1, s + 1)==0 ); + ECCODES_ASSERT( *str == *s && strcmp(str + 1, s + 1)==0 ); } #endif diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index c1c0b1f24..5fce2471f 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -166,13 +166,13 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); #define ftello ftell #endif -#define Assert(a) \ +#define ECCODES_ASSERT(a) \ do { \ if (!(a)) codes_assertion_failed(#a, __FILE__, __LINE__); \ } while (0) #ifdef DEBUG - #define DEBUG_ASSERT(a) Assert(a) + #define DEBUG_ASSERT(a) ECCODES_ASSERT(a) #define DEBUG_ASSERT_ACCESS(array, index, size) \ do { \ if (!((index) >= 0 && (index) < (size))) { \ diff --git a/src/grib_bits.cc b/src/grib_bits.cc index 7988a6f82..a400a885a 100644 --- a/src/grib_bits.cc +++ b/src/grib_bits.cc @@ -57,7 +57,7 @@ unsigned long grib_decode_unsigned_byte_long(const unsigned char* p, long o, int int i = 0; unsigned char b = p[o++]; - Assert(l <= max_nbits); + ECCODES_ASSERT(l <= max_nbits); accum <<= 8; accum |= b; @@ -77,7 +77,7 @@ long grib_decode_signed_long(const unsigned char* p, long o, int l) unsigned char b = p[o++]; int sign = grib_get_bit(&b, 0); - Assert(l <= max_nbits); + ECCODES_ASSERT(l <= max_nbits); b &= 0x7f; accum <<= 8; @@ -101,7 +101,7 @@ int grib_encode_signed_long(unsigned char* p, long val, long o, int l) int off = o; int sign = (val < 0); - Assert(l <= max_nbits); + ECCODES_ASSERT(l <= max_nbits); if (sign) val *= -1; @@ -158,7 +158,7 @@ long grib_decode_signed_longb(const unsigned char* p, long* bitp, long nbits) const int sign = grib_get_bit(p, *bitp); long val = 0; - Assert(nbits <= max_nbits); + ECCODES_ASSERT(nbits <= max_nbits); *bitp += 1; @@ -174,7 +174,7 @@ int grib_encode_signed_longb(unsigned char* p, long val, long* bitp, long nb) { const short sign = val < 0; - Assert(nb <= max_nbits); + ECCODES_ASSERT(nb <= max_nbits); if (sign) { val = -val; diff --git a/src/grib_bits_any_endian.cc b/src/grib_bits_any_endian.cc index 3b7327c28..573a99ff1 100644 --- a/src/grib_bits_any_endian.cc +++ b/src/grib_bits_any_endian.cc @@ -103,7 +103,7 @@ int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberO char str[512] = {0,}; char* s = str; - Assert(numberOfCharacters < 512); + ECCODES_ASSERT(numberOfCharacters < 512); /* There is a case where string == NULL: * bufr_dump -Efortran data/bufr/btem_109.bufr @@ -210,13 +210,13 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long if (mod != 0) { int e = grib_decode_unsigned_long(p, bitp, mod); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= mod; } while (bits > max_nbits) { int e = grib_decode_unsigned_long(p, bitp, max_nbits); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= max_nbits; } @@ -276,14 +276,14 @@ int grib_encode_unsigned_long(unsigned char* p, unsigned long val, long* bitp, l if (mod != 0) { int e = grib_encode_unsigned_long(p, zero, bitp, mod); /* printf(" -> : encoding %ld bits=%ld %ld\n",zero,(long)mod,*bitp); */ - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= mod; } while (bits > max_nbits) { int e = grib_encode_unsigned_long(p, zero, bitp, max_nbits); /* printf(" -> : encoding %ld bits=%ld %ld\n",zero,(long)max_nbits,*bitp); */ - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= max_nbits; } @@ -343,13 +343,13 @@ size_t grib_decode_size_t(const unsigned char* p, long* bitp, long nbits) if (mod != 0) { int e = grib_decode_size_t(p, bitp, mod); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= mod; } while (bits > max_nbits_size_t) { int e = grib_decode_size_t(p, bitp, max_nbits_size_t); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= max_nbits_size_t; } @@ -387,7 +387,7 @@ int grib_encode_unsigned_longb(unsigned char* p, unsigned long val, long* bitp, { if (nb > max_nbits) { fprintf(stderr, "Number of bits (%ld) exceeds maximum number of bits (%d)\n", nb, max_nbits); - Assert(0); + ECCODES_ASSERT(0); return GRIB_INTERNAL_ERROR; } @@ -413,7 +413,7 @@ int grib_encode_size_tb(unsigned char* p, size_t val, long* bitp, long nb) { if (nb > max_nbits_size_t) { fprintf(stderr, "Number of bits (%ld) exceeds maximum number of bits (%d)\n", nb, max_nbits_size_t); - Assert(0); + ECCODES_ASSERT(0); } const size_t maxV = codes_power(nb, 2) - 1; diff --git a/src/grib_bits_any_endian_omp.cc b/src/grib_bits_any_endian_omp.cc index 31e2c4df5..55fb6c3b6 100644 --- a/src/grib_bits_any_endian_omp.cc +++ b/src/grib_bits_any_endian_omp.cc @@ -37,7 +37,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue while (bitsToRead > 0) { ret <<= 8; /* ret += p[pi]; */ - /* Assert( (ret & p[pi]) == 0 ); */ + /* ECCODES_ASSERT( (ret & p[pi]) == 0 ); */ ret = ret | p[pi]; pi++; bitsToRead -= usefulBitsInByte; diff --git a/src/grib_bits_any_endian_simple.cc b/src/grib_bits_any_endian_simple.cc index c01516bc0..261d1bb56 100644 --- a/src/grib_bits_any_endian_simple.cc +++ b/src/grib_bits_any_endian_simple.cc @@ -40,7 +40,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue while (bitsToRead > 0) { ret <<= 8; /* ret += p[pi]; */ - /* Assert( (ret & p[pi]) == 0 ); */ + /* ECCODES_ASSERT( (ret & p[pi]) == 0 ); */ ret = ret | p[pi]; pi++; bitsToRead -= usefulBitsInByte; diff --git a/src/grib_bits_fast_big_endian.cc b/src/grib_bits_fast_big_endian.cc index 9efed3f64..fa9e7cd3c 100644 --- a/src/grib_bits_fast_big_endian.cc +++ b/src/grib_bits_fast_big_endian.cc @@ -58,7 +58,7 @@ int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberO int remainderComplement = 8 - remainder; const char* s = string; - Assert(numberOfCharacters < 512 && (numberOfCharacters == 0 || string)); + ECCODES_ASSERT(numberOfCharacters < 512 && (numberOfCharacters == 0 || string)); /* if (remainder) byteOffset++; */ diff --git a/src/grib_bits_fast_big_endian_vector.cc b/src/grib_bits_fast_big_endian_vector.cc index 0304672bd..fa3301c7c 100644 --- a/src/grib_bits_fast_big_endian_vector.cc +++ b/src/grib_bits_fast_big_endian_vector.cc @@ -33,7 +33,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long nbits, size_ sizel++; x = malloc(sizel * sizeof(unsigned long)); - Assert(x); + ECCODES_ASSERT(x); memcpy(x, p + bitpv / 8, sizel * sizeof(*x)); /* (void) ftrace_region_end ("gdda-1"); */ @@ -132,7 +132,7 @@ int grib_decode_double_array(const unsigned char* p, long* bitp, long nbits, dou sizel++; x = malloc(sizel * sizeof(unsigned long)); - Assert(x); + ECCODES_ASSERT(x); memcpy(x, p + bitpv / 8, sizel * sizeof(*x)); /* (void) ftrace_region_end ("gdda-1"); */ @@ -224,7 +224,7 @@ int grib_decode_double_array_complex(const unsigned char* p, long* bitp, long nb sizel++; x = malloc(sizel * sizeof(unsigned long)); - Assert(x); + ECCODES_ASSERT(x); memcpy(x, p + bitpv / 8, sizel * sizeof(*x)); if ((max_nbits % nbits == 0) && (bitpv % nbits == 0)) { @@ -277,7 +277,7 @@ int grib_encode_double_array(size_t size, const double* val, long nbits, double sizel++; destination = malloc(sizel * sizeof(unsigned long)); - Assert(destination); + ECCODES_ASSERT(destination); if ((max_nbits % nbits == 0)) { for (i = 0; i < size; i++) { @@ -341,7 +341,7 @@ int grib_encode_double_array_complex(size_t size, double* restrict val, long nbi sizel++; destination = malloc(sizel * sizeof(unsigned long)); - Assert(destination); + ECCODES_ASSERT(destination); if ((max_nbits % nbits == 0)) { for (i = 0; i < size; i++) { diff --git a/src/grib_bits_ibmpow.cc b/src/grib_bits_ibmpow.cc index c05b231ef..890981e83 100644 --- a/src/grib_bits_ibmpow.cc +++ b/src/grib_bits_ibmpow.cc @@ -25,13 +25,13 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long if (mod != 0) { int e = grib_decode_unsigned_long(p, bitp, mod); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= mod; } while (bits > max_nbits) { int e = grib_decode_unsigned_long(p, bitp, max_nbits); - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= max_nbits; } @@ -78,14 +78,14 @@ int grib_encode_unsigned_long(unsigned char* p, unsigned long val, long* bitp, l if (mod != 0) { int e = grib_encode_unsigned_long(p, zero, bitp, mod); /* printf(" -> : encoding %ld bits=%ld %ld\n",zero,(long)mod,*bitp); */ - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= mod; } while (bits > max_nbits) { int e = grib_encode_unsigned_long(p, zero, bitp, max_nbits); /* printf(" -> : encoding %ld bits=%ld %ld\n",zero,(long)max_nbits,*bitp); */ - Assert(e == 0); + ECCODES_ASSERT(e == 0); bits -= max_nbits; } @@ -128,7 +128,7 @@ int grib_encode_unsigned_longb(unsigned char* p, unsigned long val, long* bitp, { long i = 0; - Assert(nb <= max_nbits); + ECCODES_ASSERT(nb <= max_nbits); for (i = nb - 1; i >= 0; i--) { if (test(val, i)) diff --git a/src/grib_bufr_descriptor.cc b/src/grib_bufr_descriptor.cc index 3f83f6ec7..950af7dfc 100644 --- a/src/grib_bufr_descriptor.cc +++ b/src/grib_bufr_descriptor.cc @@ -52,12 +52,12 @@ bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d) int grib_bufr_descriptor_set_code(bufr_descriptor* v, int code) { if (!v) return GRIB_NULL_POINTER; - Assert(v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION || v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR); + ECCODES_ASSERT(v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION || v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR); v->code = code; v->F = code / 100000; - if (v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION) Assert(v->F == 1); - if (v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR) Assert(v->F == 2); + if (v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION) ECCODES_ASSERT(v->F == 1); + if (v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR) ECCODES_ASSERT(v->F == 2); v->X = (code - v->F * 100000) / 1000; v->Y = (code - v->F * 100000) % 1000; diff --git a/src/grib_context.cc b/src/grib_context.cc index 2e067038e..b30162f48 100644 --- a/src/grib_context.cc +++ b/src/grib_context.cc @@ -205,7 +205,7 @@ static void default_log(const grib_context* c, int level, const char* mess) c = grib_context_get_default(); if (level == GRIB_LOG_ERROR) { fprintf(c->log_stream, "ECCODES ERROR : %s\n", mess); - /*Assert(1==0);*/ + /*ECCODES_ASSERT(1==0);*/ } if (level == GRIB_LOG_FATAL) fprintf(c->log_stream, "ECCODES ERROR : %s\n", mess); @@ -217,15 +217,15 @@ static void default_log(const grib_context* c, int level, const char* mess) fprintf(c->log_stream, "ECCODES INFO : %s\n", mess); if (level == GRIB_LOG_FATAL) { - Assert(0); + ECCODES_ASSERT(0); } if (getenv("ECCODES_FAIL_IF_LOG_MESSAGE")) { long n = atol(getenv("ECCODES_FAIL_IF_LOG_MESSAGE")); if (n >= 1 && level == GRIB_LOG_ERROR) - Assert(0); + ECCODES_ASSERT(0); if (n >= 2 && level == GRIB_LOG_WARNING) - Assert(0); + ECCODES_ASSERT(0); } } @@ -247,7 +247,7 @@ void grib_context_set_data_quality_checks(grib_context* c, int val) // If val == 0, disable data quality checks // If val == 1, failure results in an error // If val == 2, failure results in a warning - Assert(val == 0 || val == 1 || val == 2); + ECCODES_ASSERT(val == 0 || val == 1 || val == 2); c->grib_data_quality_checks = val; } @@ -736,7 +736,7 @@ char* grib_context_full_defs_path(grib_context* c, const char* basename) snprintf(full, sizeof(full), "%s/%s", dir->value, basename); if (codes_access(full, F_OK) == 0) { /* 0 means file exists */ fullpath = (grib_string_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_string_list)); - Assert(fullpath); + ECCODES_ASSERT(fullpath); fullpath->value = grib_context_strdup(c, full); GRIB_MUTEX_LOCK(&mutex_c); grib_trie_insert(c->def_files, basename, fullpath); diff --git a/src/grib_darray.cc b/src/grib_darray.cc index 7f94fbb87..544396c5d 100644 --- a/src/grib_darray.cc +++ b/src/grib_darray.cc @@ -14,7 +14,7 @@ void grib_darray_print(const char* title, const grib_darray* darray) { size_t i; - Assert(darray); + ECCODES_ASSERT(darray); printf("%s: darray.n=%zu \t", title, darray->n); for (i = 0; i < darray->n; i++) { printf("darray[%zu]=%g\t", i, darray->v[i]); diff --git a/src/grib_dependency.cc b/src/grib_dependency.cc index 309c7677b..8efb8255d 100644 --- a/src/grib_dependency.cc +++ b/src/grib_dependency.cc @@ -57,7 +57,7 @@ void grib_dependency_add(grib_accessor* observer, grib_accessor* observed) h = handle_of(observed); d = h->dependencies; - /* Assert(h == handle_of(observer)); */ + /* ECCODES_ASSERT(h == handle_of(observer)); */ /* Check if already in list */ while (d) { @@ -75,7 +75,7 @@ void grib_dependency_add(grib_accessor* observer, grib_accessor* observed) // } d = (grib_dependency*)grib_context_malloc_clear(h->context, sizeof(grib_dependency)); - Assert(d); + ECCODES_ASSERT(d); d->observed = observed; d->observer = observer; diff --git a/src/grib_dumper_factory.cc b/src/grib_dumper_factory.cc index c8e0baf30..3c05b7702 100644 --- a/src/grib_dumper_factory.cc +++ b/src/grib_dumper_factory.cc @@ -144,7 +144,7 @@ eccodes::Dumper *grib_dump_content_with_dumper(grib_handle *h, eccodes::Dumper * void codes_dump_bufr_flat(grib_accessors_list *al, grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data) { eccodes::Dumper *dumper = NULL; - Assert(h->product_kind == PRODUCT_BUFR); + ECCODES_ASSERT(h->product_kind == PRODUCT_BUFR); dumper = grib_dumper_factory(mode ? mode : "serialize", h, f, flags, data); if (!dumper) return; diff --git a/src/grib_handle.cc b/src/grib_handle.cc index 830b97723..21bb92518 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -434,7 +434,7 @@ grib_handle* codes_handle_new_from_file(grib_context* c, FILE* f, ProductKind pr if (product == PRODUCT_ANY) return any_new_from_file(c, f, error); - Assert(!"codes_handle_new_from_file: Invalid product"); + ECCODES_ASSERT(!"codes_handle_new_from_file: Invalid product"); return NULL; } @@ -1417,9 +1417,9 @@ int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind) int codes_check_message_header(const void* bytes, size_t length, ProductKind product) { const char* p = ((const char*)bytes); - Assert(p); - Assert(product == PRODUCT_GRIB || product == PRODUCT_BUFR); /* Others not yet implemented */ - Assert(length > 4); + ECCODES_ASSERT(p); + ECCODES_ASSERT(product == PRODUCT_GRIB || product == PRODUCT_BUFR); /* Others not yet implemented */ + ECCODES_ASSERT(length > 4); if (product == PRODUCT_GRIB) { if (p[0] != 'G' || p[1] != 'R' || p[2] != 'I' || p[3] != 'B') return GRIB_INVALID_MESSAGE; @@ -1437,8 +1437,8 @@ int codes_check_message_header(const void* bytes, size_t length, ProductKind pro int codes_check_message_footer(const void* bytes, size_t length, ProductKind product) { const char* p = ((const char*)bytes); - Assert(p); - Assert(product == PRODUCT_GRIB || product == PRODUCT_BUFR); /* Others not yet implemented */ + ECCODES_ASSERT(p); + ECCODES_ASSERT(product == PRODUCT_GRIB || product == PRODUCT_BUFR); /* Others not yet implemented */ if (p[length - 4] != '7' || p[length - 3] != '7' || p[length - 2] != '7' || p[length - 1] != '7') { return GRIB_7777_NOT_FOUND; diff --git a/src/grib_hash_keys.cc b/src/grib_hash_keys.cc index aa24e9aa6..c981c606f 100644 --- a/src/grib_hash_keys.cc +++ b/src/grib_hash_keys.cc @@ -10979,7 +10979,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key) GRIB_MUTEX_INIT_ONCE(&once, &init_mutex); GRIB_MUTEX_LOCK(&mutex); - Assert(t); + ECCODES_ASSERT(t); if (!t) return -1; count = t->count; @@ -11006,7 +11006,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key) else { grib_context_log(t->context, GRIB_LOG_ERROR, "grib_hash_keys_insert: too many accessors, increase ACCESSORS_ARRAY_SIZE\n"); - Assert(*(t->count) + TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE); + ECCODES_ASSERT(*(t->count) + TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE); } GRIB_MUTEX_UNLOCK(&mutex); diff --git a/src/grib_iarray.cc b/src/grib_iarray.cc index 85ad7bca5..90fef0c52 100644 --- a/src/grib_iarray.cc +++ b/src/grib_iarray.cc @@ -14,7 +14,7 @@ void grib_iarray_print(const char* title, const grib_iarray* iarray) { size_t i; - Assert(iarray); + ECCODES_ASSERT(iarray); printf("%s: iarray.n=%zu \t", title, iarray->n); for (i = 0; i < iarray->n; i++) { printf("iarray[%zu]=%ld\t", i, iarray->v[i]); @@ -69,7 +69,7 @@ long grib_iarray_pop_front(grib_iarray* a) long v = a->v[0]; /* size_t i=0; */ if (a->n == 0) - Assert(0); + ECCODES_ASSERT(0); a->n--; a->v++; a->number_of_pop_front++; diff --git a/src/grib_ibmfloat.cc b/src/grib_ibmfloat.cc index 47f0eda35..c2b17d543 100644 --- a/src/grib_ibmfloat.cc +++ b/src/grib_ibmfloat.cc @@ -55,7 +55,7 @@ unsigned long grib_ibm_to_long(double x) /* Overflow */ if (x > ibm_table.vmax) { fprintf(stderr, "grib_ibm_to_long: Number is too large: x=%.20e > xmax=%.20e\n", x, ibm_table.vmax); - Assert(0); + ECCODES_ASSERT(0); return 0; } @@ -106,7 +106,7 @@ double grib_ibmfloat_error(double x) /* Overflow */ if (x > ibm_table.vmax) { fprintf(stderr, "grib_ibmfloat_error: Number is too large: x=%.20e > xmax=%.20e\n", x, ibm_table.vmax); - Assert(0); + ECCODES_ASSERT(0); return 0; } @@ -190,7 +190,7 @@ unsigned long grib_ibm_nearest_smaller_to_long(double x) l = grib_ibm_to_long(x - eps); if (x < grib_long_to_ibm(l)) { printf("grib_ibm_nearest_smaller_to_long: x=%.20e grib_long_to_ibm(0x%lX)=%.20e\n", x, l, grib_long_to_ibm(l)); - Assert(x >= grib_long_to_ibm(l)); + ECCODES_ASSERT(x >= grib_long_to_ibm(l)); } } diff --git a/src/grib_ieeefloat.cc b/src/grib_ieeefloat.cc index 5c8ffbb18..834b92f27 100644 --- a/src/grib_ieeefloat.cc +++ b/src/grib_ieeefloat.cc @@ -56,7 +56,7 @@ unsigned long grib_ieee_to_long(double x) /* Overflow */ if (x > ieee_table.vmax) { fprintf(stderr, "grib_ieee_to_long: Number is too large: x=%.20e > xmax=%.20e\n", x, ieee_table.vmax); - Assert(0); + ECCODES_ASSERT(0); return 0; } @@ -107,7 +107,7 @@ double grib_ieeefloat_error(double x) /* Overflow */ if (x > ieee_table.vmax) { fprintf(stderr, "grib_ieeefloat_error: Number is too large: x=%.20e > xmax=%.20e\n", x, ieee_table.vmax); - Assert(0); + ECCODES_ASSERT(0); return 0; } @@ -127,7 +127,7 @@ double grib_long_to_ieee(unsigned long x) #ifdef DEBUG if (x > 0 && x < 0x800000) { fprintf(stderr, "grib_long_to_ieee: Invalid input %lu\n", x); - Assert(0); + ECCODES_ASSERT(0); } #endif @@ -195,7 +195,7 @@ unsigned long grib_ieee_nearest_smaller_to_long(double x) if (x < grib_long_to_ieee(l)) { printf("grib_ieee_nearest_smaller_to_long: x=%.20e grib_long_to_ieee(0x%lX)=%.20e\n", x, l, grib_long_to_ieee(l)); - Assert(x >= grib_long_to_ieee(l)); + ECCODES_ASSERT(x >= grib_long_to_ieee(l)); } return l; diff --git a/src/grib_index.cc b/src/grib_index.cc index 0a96b57e3..cfeab1202 100644 --- a/src/grib_index.cc +++ b/src/grib_index.cc @@ -840,7 +840,7 @@ int grib_index_write(grib_index* index, const char* filename) if (index->product_kind == PRODUCT_GRIB) identifier = "GRBIDX1"; if (index->product_kind == PRODUCT_BUFR) identifier = "BFRIDX1"; - Assert(identifier); + ECCODES_ASSERT(identifier); err = grib_write_identifier(fh, identifier); if (err) { grib_context_log(index->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), @@ -1061,7 +1061,7 @@ static grib_handle* new_message_from_file(int message_type, grib_context* c, FIL return grib_new_from_file(c, f, 0, error); /* headers_only=0 */ if (message_type == CODES_BUFR) return bufr_new_from_file(c, f, error); - Assert(!"new_message_from_file: invalid message type"); + ECCODES_ASSERT(!"new_message_from_file: invalid message type"); return NULL; } @@ -1597,7 +1597,7 @@ int grib_index_select_long(grib_index* index, const char* skey, long value) "key \"%s\" not found in index", skey); return err; } - Assert(key); + ECCODES_ASSERT(key); snprintf(key->value, sizeof(key->value), "%ld", value); grib_index_rewind(index); return 0; @@ -1629,7 +1629,7 @@ int grib_index_select_double(grib_index* index, const char* skey, double value) "key \"%s\" not found in index", skey); return err; } - Assert(key); + ECCODES_ASSERT(key); snprintf(key->value, sizeof(key->value), "%g", value); grib_index_rewind(index); return 0; @@ -1661,7 +1661,7 @@ int grib_index_select_string(grib_index* index, const char* skey, const char* va "key \"%s\" not found in index", skey); return err; } - Assert(key); + ECCODES_ASSERT(key); snprintf(key->value, sizeof(key->value), "%s", value); grib_index_rewind(index); return 0; @@ -1816,8 +1816,8 @@ int grib_index_dump_file(FILE* fout, const char* filename, unsigned long flags) grib_context* c = grib_context_get_default(); FILE* fh = NULL; - Assert(fout); - Assert(filename); + ECCODES_ASSERT(fout); + ECCODES_ASSERT(filename); index = grib_index_read(c, filename, &err); if (err) return err; @@ -1860,7 +1860,7 @@ void grib_index_dump(FILE* fout, grib_index* index, unsigned long flags) { if (!index) return; - Assert(fout); + ECCODES_ASSERT(fout); /* The grib_dump_files does not print anything as */ /* the index object does not store the file names! */ diff --git a/src/grib_io.cc b/src/grib_io.cc index 4de9e4599..0cbb44e58 100644 --- a/src/grib_io.cc +++ b/src/grib_io.cc @@ -423,7 +423,7 @@ static int read_GRIB(reader* r, int no_alloc) return GRIB_UNSUPPORTED_EDITION; } - /* Assert(i <= buf->length); */ + /* ECCODES_ASSERT(i <= buf->length); */ err = read_the_rest(r, length, tmp, i, /*check7777=*/1, no_alloc); if (err) r->seek_from_start(r->read_data, r->offset + 4); @@ -441,7 +441,7 @@ static int read_PSEUDO(reader* r, const char* type, int no_alloc) int err = 0; int i = 0, j = 0; - Assert(strlen(type) == 4); + ECCODES_ASSERT(strlen(type) == 4); for (j = 0; j < 4; j++) { tmp[i] = type[i]; i++; @@ -478,7 +478,7 @@ static int read_PSEUDO(reader* r, const char* type, int no_alloc) /* fprintf(stderr,"%s sec4len=%d i=%d l=%d\n",type,sec4len,i,4+sec1len+sec4len+4); */ - Assert(i <= sizeof(tmp)); + ECCODES_ASSERT(i <= sizeof(tmp)); return read_the_rest(r, 4 + sec1len + sec4len + 4, tmp, i, /*check7777=*/1, no_alloc); } @@ -665,7 +665,7 @@ static int read_HDF5(reader* r) return GRIB_NOT_IMPLEMENTED; } - Assert(i <= sizeof(tmp)); + ECCODES_ASSERT(i <= sizeof(tmp)); return read_the_rest(r, end_of_file_address, tmp, i, 0, 0); } @@ -697,7 +697,7 @@ static int read_WRAP(reader* r) tmp[i++] = buf[j]; } - Assert(i <= sizeof(tmp)); + ECCODES_ASSERT(i <= sizeof(tmp)); return read_the_rest(r, length, tmp, i, 1, 0); } @@ -747,7 +747,7 @@ static int read_BUFR(reader* r, int no_alloc) edition = tmp[i++]; - /* Assert(edition != 1); */ + /* ECCODES_ASSERT(edition != 1); */ switch (edition) { case 0: @@ -852,7 +852,7 @@ static int read_BUFR(reader* r, int no_alloc) return GRIB_UNSUPPORTED_EDITION; } - /* Assert(i <= sizeof(tmp)); */ + /* ECCODES_ASSERT(i <= sizeof(tmp)); */ err = read_the_rest(r, length, tmp, i, /*check7777=*/1, no_alloc); if (err) r->seek_from_start(r->read_data, r->offset + 4); diff --git a/src/grib_itrie.cc b/src/grib_itrie.cc index 6689e1bf8..9c47142cb 100644 --- a/src/grib_itrie.cc +++ b/src/grib_itrie.cc @@ -339,7 +339,7 @@ int grib_itrie_get_id(grib_itrie* t, const char* key) const char* k = key; grib_itrie* last = t; if (!t) { - Assert(!"grib_itrie_get_id: grib_trie==NULL"); + ECCODES_ASSERT(!"grib_itrie_get_id: grib_trie==NULL"); return -1; } @@ -367,7 +367,7 @@ int grib_itrie_insert(grib_itrie* t, const char* key) int* count; if (!t) { - Assert(!"grib_itrie_insert: grib_trie==NULL"); + ECCODES_ASSERT(!"grib_itrie_insert: grib_trie==NULL"); return -1; } @@ -398,7 +398,7 @@ int grib_itrie_insert(grib_itrie* t, const char* key) else { grib_context_log(t->context, GRIB_LOG_ERROR, "grib_itrie_insert: too many accessors, increase MAX_NUM_CONCEPTS\n"); - Assert(*(t->count) < MAX_NUM_CONCEPTS); + ECCODES_ASSERT(*(t->count) < MAX_NUM_CONCEPTS); } GRIB_MUTEX_UNLOCK(&mutex); diff --git a/src/grib_itrie_keys.cc b/src/grib_itrie_keys.cc index 2ee7291c6..f141182e1 100644 --- a/src/grib_itrie_keys.cc +++ b/src/grib_itrie_keys.cc @@ -341,7 +341,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key) GRIB_MUTEX_INIT_ONCE(&once, &init_mutex); GRIB_MUTEX_LOCK(&mutex); - Assert(t); + ECCODES_ASSERT(t); if (!t) return -1; count = t->count; @@ -368,7 +368,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key) else { grib_context_log(t->context, GRIB_LOG_ERROR, "grib_hash_keys_insert: too many accessors, increase ACCESSORS_ARRAY_SIZE\n"); - Assert(*(t->count) + TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE); + ECCODES_ASSERT(*(t->count) + TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE); } GRIB_MUTEX_UNLOCK(&mutex); diff --git a/src/grib_jasper_encoding.cc b/src/grib_jasper_encoding.cc index ac545555a..ad5c24562 100644 --- a/src/grib_jasper_encoding.cc +++ b/src/grib_jasper_encoding.cc @@ -120,7 +120,7 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen goto cleanup; } - Assert(p->height_ * p->width_ == *n_vals); + ECCODES_ASSERT(p->height_ * p->width_ == *n_vals); k = 0; for (i = 0; i < p->height_; i++) @@ -193,7 +193,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) /* Simple packing encoding */ bits8 = (helper->bits_per_value + 7) / 8 * 8; - Assert(bits8 > 0); + ECCODES_ASSERT(bits8 > 0); encoded = (unsigned char*)grib_context_malloc_clear(c, bits8 / 8 * no_values); if (!encoded) { @@ -224,7 +224,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) snprintf(opts, MAXOPTSSIZE, "mode=real\nrate=%f", 1.0 / helper->compression); } - Assert(cmpt.width_ * cmpt.height_ * cmpt.cps_ == buflen); + ECCODES_ASSERT(cmpt.width_ * cmpt.height_ * cmpt.cps_ == buflen); grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_encode: JasPer version %s", jas_getversion()); pcmpt = &cmpt; diff --git a/src/grib_keys_iterator.cc b/src/grib_keys_iterator.cc index 103f98591..3b7c6a0a3 100644 --- a/src/grib_keys_iterator.cc +++ b/src/grib_keys_iterator.cc @@ -177,7 +177,7 @@ int grib_keys_iterator_next(grib_keys_iterator* kiter) const char* grib_keys_iterator_get_name(const grib_keys_iterator* kiter) { /* if(kiter->name_space) */ - Assert(kiter->current); + ECCODES_ASSERT(kiter->current); return kiter->current->all_names_[kiter->match]; } diff --git a/src/grib_memory.cc b/src/grib_memory.cc index b44e12c19..97dc3982f 100644 --- a/src/grib_memory.cc +++ b/src/grib_memory.cc @@ -190,7 +190,7 @@ static void fast_delete(void* p, mempool* pool) n = m; m = m->next; } - Assert(1 == 0); + ECCODES_ASSERT(1 == 0); } static void* fast_realloc(void* p, size_t s, mempool* pool) diff --git a/src/grib_openjpeg_encoding.cc b/src/grib_openjpeg_encoding.cc index f03ba2fcb..f79bea019 100644 --- a/src/grib_openjpeg_encoding.cc +++ b/src/grib_openjpeg_encoding.cc @@ -93,9 +93,9 @@ int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper) image->x1 = helper->width; image->y1 = helper->height; - Assert(cmptparm.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ + ECCODES_ASSERT(cmptparm.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ - Assert(helper->no_values == image->comps[0].h * image->comps[0].w); + ECCODES_ASSERT(helper->no_values == image->comps[0].h * image->comps[0].w); /* Simple packing */ data = image->comps[0].data; @@ -195,10 +195,10 @@ int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* bufl goto cleanup; } - Assert(image->comps[0].sgnd == 0); - Assert(comp.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ + ECCODES_ASSERT(image->comps[0].sgnd == 0); + ECCODES_ASSERT(comp.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ - Assert(image->comps[0].prec < sizeof(mask) * 8 - 1); + ECCODES_ASSERT(image->comps[0].prec < sizeof(mask) * 8 - 1); data = image->comps[0].data; mask = (1 << image->comps[0].prec) - 1; @@ -388,8 +388,8 @@ int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper) image->x1 = helper->width; image->y1 = helper->height; - Assert(cmptparm.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ - Assert(helper->no_values == image->comps[0].h * image->comps[0].w); + ECCODES_ASSERT(cmptparm.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ + ECCODES_ASSERT(helper->no_values == image->comps[0].h * image->comps[0].w); /* Simple packing */ data = image->comps[0].data; @@ -517,10 +517,10 @@ int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* bufl goto cleanup; } - Assert(image->comps[0].sgnd == 0); - Assert(comp.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ + ECCODES_ASSERT(image->comps[0].sgnd == 0); + ECCODES_ASSERT(comp.prec <= sizeof(image->comps[0].data[0]) * 8 - 1); /* BR: -1 because I don't know what happens if the sign bit is set */ - Assert(image->comps[0].prec < sizeof(mask) * 8 - 1); + ECCODES_ASSERT(image->comps[0].prec < sizeof(mask) * 8 - 1); data = image->comps[0].data; mask = (1 << image->comps[0].prec) - 1; diff --git a/src/grib_parse_utils.cc b/src/grib_parse_utils.cc index f348516da..7510f8e41 100644 --- a/src/grib_parse_utils.cc +++ b/src/grib_parse_utils.cc @@ -603,8 +603,8 @@ int grib_yywrap() if (top) { parse_file = stack[top - 1].name; grib_yyin = stack[top - 1].file; - Assert(parse_file); - Assert(grib_yyin); + ECCODES_ASSERT(parse_file); + ECCODES_ASSERT(grib_yyin); /* grib_yyrestart(grib_yyin); */ /* for(i = 0; i < top ; i++) printf(" "); */ @@ -641,14 +641,14 @@ void grib_parser_include(const char* included_fname) FILE* f = NULL; char* io_buffer = 0; /* int i; */ - Assert(top < MAXINCLUDE); - Assert(included_fname); + ECCODES_ASSERT(top < MAXINCLUDE); + ECCODES_ASSERT(included_fname); if (!included_fname) return; if (parse_file == 0) { parse_file = included_fname; - Assert(top == 0); + ECCODES_ASSERT(top == 0); } else { /* When parse_file is not NULL, it's the path of the parent file (includer) */ @@ -656,7 +656,7 @@ void grib_parser_include(const char* included_fname) /* GRIB-796: Search for the included file in ECCODES_DEFINITION_PATH */ char* new_path = NULL; - Assert(*included_fname != '/'); + ECCODES_ASSERT(*included_fname != '/'); new_path = grib_context_full_defs_path(grib_parser_context, included_fname); if (!new_path) { fprintf(stderr, "ecCodes Version: %s\nDefinition files path: %s\n", diff --git a/src/grib_sarray.cc b/src/grib_sarray.cc index f285beeb7..3356492b4 100644 --- a/src/grib_sarray.cc +++ b/src/grib_sarray.cc @@ -14,7 +14,7 @@ void grib_sarray_print(const char* title, const grib_sarray* sarray) { size_t i; - Assert(sarray); + ECCODES_ASSERT(sarray); printf("%s: sarray.n=%zu \t", title, sarray->n); for (i = 0; i < sarray->n; i++) { printf("sarray[%zu]=%s\t", i, sarray->v[i]); diff --git a/src/grib_scaling.cc b/src/grib_scaling.cc index 960e40ee3..8a69816bc 100644 --- a/src/grib_scaling.cc +++ b/src/grib_scaling.cc @@ -50,7 +50,7 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error) return 0; } - Assert(bpval >= 1); + ECCODES_ASSERT(bpval >= 1); if (range == 0) return 0; @@ -79,7 +79,7 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error) *error = GRIB_UNDERFLOW; scale = -last; } - Assert(scale <= last); + ECCODES_ASSERT(scale <= last); return scale; } @@ -113,7 +113,7 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error) // scale++; // zs /= 2; // } -// Assert(scale >= -last && scale <= last); +// ECCODES_ASSERT(scale >= -last && scale <= last); // /* printf("---- scale=%ld\n",scale);*/ // return scale; // } @@ -127,7 +127,7 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error) // unsigned long maxint = codes_power(bpval, 2) - 1; // double dmaxint = (double)maxint; // range *= codes_power(-binary_scale, 2); -// Assert(bpval >= 1); +// ECCODES_ASSERT(bpval >= 1); // if (range == 0) // return 0; // while ((range * zs) > dmaxint) { @@ -147,6 +147,6 @@ long grib_get_binary_scale_fact(double max, double min, long bpval, int* error) // zs *= 10; // } // /* printf("grib_api: decimal_scale_fact=%ld max=%g min=%g bits_per_value=%ld binary_scale=%ld\n",scale,max,min,bpval,binary_scale); */ -// Assert(scale >= -last && scale <= last); +// ECCODES_ASSERT(scale >= -last && scale <= last); // return scale; // } diff --git a/src/grib_templates.cc b/src/grib_templates.cc index ca2076a2a..3811a8131 100644 --- a/src/grib_templates.cc +++ b/src/grib_templates.cc @@ -72,7 +72,7 @@ static grib_handle* try_product_sample(grib_context* c, ProductKind product_kind off_t offset = 0; mesg = (char*)wmo_read_any_from_file_malloc(f, 0, &size, &offset, &err); if (mesg && !err) { - Assert(size > 4); + ECCODES_ASSERT(size > 4); if (strncmp(mesg, "GRIB", 4) == 0 || strncmp(mesg, "DIAG", 4) == 0 || strncmp(mesg, "BUDG", 4) == 0) { product_kind = PRODUCT_GRIB; } else if (strncmp(mesg, "BUFR", 4) == 0) { diff --git a/src/grib_trie.cc b/src/grib_trie.cc index 85f246e2d..22979babe 100644 --- a/src/grib_trie.cc +++ b/src/grib_trie.cc @@ -395,7 +395,7 @@ void* grib_trie_insert(grib_trie* t, const char* key, void* data) void* old = NULL; if (!t) { - Assert(!"grib_trie_insert: grib_trie==NULL"); + ECCODES_ASSERT(!"grib_trie_insert: grib_trie==NULL"); return NULL; } @@ -437,7 +437,7 @@ void* grib_trie_insert_no_replace(grib_trie* t, const char* key, void* data) { grib_trie* last = t; const char* k = key; - Assert(t); + ECCODES_ASSERT(t); while (*k && t) { last = t; diff --git a/src/grib_util.cc b/src/grib_util.cc index abc72d830..73f1e7787 100644 --- a/src/grib_util.cc +++ b/src/grib_util.cc @@ -354,7 +354,7 @@ static const char* get_packing_spec_packing_name(long packing_spec_packing) return "GRIB_UTIL_PACKING_USE_PROVIDED"; if (GRIB_UTIL_PACKING_SAME_AS_INPUT == packing_spec_packing) return "GRIB_UTIL_PACKING_SAME_AS_INPUT"; - Assert(!"get_packing_spec_packing_name: invalid packing"); + ECCODES_ASSERT(!"get_packing_spec_packing_name: invalid packing"); return NULL; } @@ -380,7 +380,7 @@ static const char* get_packing_spec_packing_type_name(long packing_spec_packing_ return "GRIB_UTIL_PACKING_TYPE_CCSDS"; if (GRIB_UTIL_PACKING_TYPE_IEEE == packing_spec_packing_type) return "GRIB_UTIL_PACKING_TYPE_IEEE"; - Assert(!"get_packing_spec_packing_type_name: invalid packing_type"); + ECCODES_ASSERT(!"get_packing_spec_packing_type_name: invalid packing_type"); return NULL; } @@ -487,7 +487,7 @@ static void print_values(const grib_context* c, // static int angle_can_be_encoded(const double angle, const double angular_precision) // { // const double angle_expanded = angle * angular_precision; -// Assert(angular_precision>0); +// ECCODES_ASSERT(angular_precision>0); // double rounded = (long)(angle_expanded+0.5)/angular_precision; // if (angle<0) { // rounded = (long)(angle_expanded-0.5)/angular_precision; @@ -512,7 +512,7 @@ static int angle_can_be_encoded(const grib_handle* h, const double angle) return ret; if ((ret = grib_get_long(h, "angleSubdivisions", &angle_subdivisions)) != 0) return ret; - Assert(angle_subdivisions > 0); + ECCODES_ASSERT(angle_subdivisions > 0); snprintf(sample_name, sizeof(sample_name), "GRIB%ld", edition); h2 = grib_handle_new_from_samples(0, sample_name); @@ -535,7 +535,7 @@ static int angle_can_be_encoded(const grib_handle* h, const double angle) static double adjust_angle(const double angle, const RoundingPolicy policy, const double angle_subdivisions) { double result = 0; - Assert(angle_subdivisions > 0); + ECCODES_ASSERT(angle_subdivisions > 0); result = angle * angle_subdivisions; if (policy == eROUND_ANGLE_UP) result = round(result + 0.5); @@ -938,7 +938,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, { #define SET_LONG_VALUE(n, v) \ do { \ - Assert(count < 1024); \ + ECCODES_ASSERT(count < 1024); \ values[count].name = n; \ values[count].type = GRIB_TYPE_LONG; \ values[count].long_value = v; \ @@ -946,7 +946,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, } while (0) #define SET_DOUBLE_VALUE(n, v) \ do { \ - Assert(count < 1024); \ + ECCODES_ASSERT(count < 1024); \ values[count].name = n; \ values[count].type = GRIB_TYPE_DOUBLE; \ values[count].double_value = v; \ @@ -954,7 +954,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, } while (0) #define SET_STRING_VALUE(n, v) \ do { \ - Assert(count < 1024); \ + ECCODES_ASSERT(count < 1024); \ values[count].name = n; \ values[count].type = GRIB_TYPE_STRING; \ values[count].string_value = v; \ @@ -963,7 +963,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, #define COPY_SPEC_LONG(x) \ do { \ - Assert(count < 1024); \ + ECCODES_ASSERT(count < 1024); \ values[count].name = #x; \ values[count].type = GRIB_TYPE_LONG; \ values[count].long_value = spec->x; \ @@ -971,7 +971,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, } while (0) #define COPY_SPEC_DOUBLE(x) \ do { \ - Assert(count < 1024); \ + ECCODES_ASSERT(count < 1024); \ values[count].name = #x; \ values[count].type = GRIB_TYPE_DOUBLE; \ values[count].double_value = spec->x; \ @@ -995,7 +995,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, bool global_grid = false; int expandBoundingBox = 0; - Assert(h); + ECCODES_ASSERT(h); // Get edition number from input handle if ((*err = grib_get_long(h, "edition", &editionNumber)) != 0) { @@ -1106,7 +1106,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, if (spec->missingValue) COPY_SPEC_DOUBLE(missingValue); SET_LONG_VALUE("ijDirectionIncrementGiven", 1); - // TODO(masn): add Assert + // TODO(masn): add ECCODES_ASSERT COPY_SPEC_LONG(Ni); COPY_SPEC_DOUBLE(iDirectionIncrementInDegrees); COPY_SPEC_LONG(Nj); @@ -1352,7 +1352,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, } else { - Assert(grib_get_long(h, "bitsPerValue", &bitsPerValue) == 0); + ECCODES_ASSERT(grib_get_long(h, "bitsPerValue", &bitsPerValue) == 0); SET_LONG_VALUE("bitsPerValue", bitsPerValue); } } @@ -1371,7 +1371,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, case GRIB_UTIL_ACCURACY_SAME_DECIMAL_SCALE_FACTOR_AS_INPUT: { long decimalScaleFactor = 0; - Assert(grib_get_long(h, "decimalScaleFactor", &decimalScaleFactor) == 0); + ECCODES_ASSERT(grib_get_long(h, "decimalScaleFactor", &decimalScaleFactor) == 0); SET_LONG_VALUE("decimalScaleFactor", decimalScaleFactor); } break; @@ -1389,7 +1389,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, if (packing_spec->extra_settings_count) { for (i = 0; i < packing_spec->extra_settings_count; i++) { - Assert(count < 1024); + ECCODES_ASSERT(count < 1024); if (strcmp(packing_spec->extra_settings[i].name, "expandBoundingBox") == 0) { if (packing_spec->extra_settings[i].long_value == 1) { /* ECC-625: Request is for expansion of bounding box (sub-area). @@ -1416,10 +1416,10 @@ grib_handle* grib_util_set_spec(grib_handle* h, } grib_handle_delete(h_sample); - Assert(*err == 0); + ECCODES_ASSERT(*err == 0); // GRIB-857: Set "pl" array if provided (For reduced Gaussian grids) - Assert(spec->pl_size >= 0); + ECCODES_ASSERT(spec->pl_size >= 0); if (spec->pl && spec->pl_size == 0) { fprintf(stderr, "%s: pl array not NULL but pl_size == 0!\n", __func__); goto cleanup; @@ -1598,7 +1598,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, // ECC-445 if (expandBoundingBox) { - Assert(!global_grid); // ECC-576: "global" should not be set + ECCODES_ASSERT(!global_grid); // ECC-576: "global" should not be set } if ((*err = check_geometry(h_out, spec, data_values_count, global_grid)) != GRIB_SUCCESS) { @@ -1829,7 +1829,7 @@ int parse_keyval_string(const char* grib_tool, p = strtok_r(arg, ",", &lasts); while (p != NULL) { values[i].name = (char*)calloc(1, strlen(p) + 1); - Assert(values[i].name); + ECCODES_ASSERT(values[i].name); strcpy((char*)values[i].name, p); p = strtok_r(NULL, ",", &lasts); i++; @@ -2037,7 +2037,7 @@ int grib2_select_PDTN(int is_eps, int is_instant, // At most one has to be set. All could be 0 // Unfortunately if PDTN=48 then both aerosol and aerosol_optical can be 1! const int sum = is_chemical + is_chemical_srcsink + is_chemical_distfn + is_aerosol + is_aerosol_optical; - Assert(sum == 0 || sum == 1 || sum == 2); + ECCODES_ASSERT(sum == 0 || sum == 1 || sum == 2); if (is_chemical) { if (is_eps) { @@ -2228,7 +2228,7 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max // If grib_data_quality_checks == 1, limits failure results in an error // If grib_data_quality_checks == 2, limits failure results in a warning - Assert(ctx->grib_data_quality_checks == 1 || ctx->grib_data_quality_checks == 2); + ECCODES_ASSERT(ctx->grib_data_quality_checks == 1 || ctx->grib_data_quality_checks == 2); is_error = (ctx->grib_data_quality_checks == 1); len = sizeof(shortName); diff --git a/src/grib_value.cc b/src/grib_value.cc index c3cf55e55..ec2076a50 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -39,7 +39,7 @@ static void print_debug_info__set_array(grib_handle* h, const char* func, const T minVal = std::numeric_limits::max(); T maxVal = -std::numeric_limits::max(); double missingValue = 0; - Assert( h->context->debug ); + ECCODES_ASSERT( h->context->debug ); if (grib_get_double(h, "missingValue", &missingValue)!=GRIB_SUCCESS) { missingValue = 9999.0; @@ -1373,8 +1373,8 @@ int grib_get_float_array(const grib_handle* h, const char* name, float* val, siz //grib_context_log(h->context, GRIB_LOG_ERROR, "grib_get_float_array only supported for GRIB"); return GRIB_NOT_IMPLEMENTED; } - Assert(name[0]!='/'); - Assert(name[0]!='#'); + ECCODES_ASSERT(name[0]!='/'); + ECCODES_ASSERT(name[0]!='#'); *length = 0; return _grib_get_array_internal(h,a,val,len,length); } @@ -1796,7 +1796,7 @@ int grib_set_values_silent(grib_handle* h, grib_values* args, size_t count, int int more = 1; int stack = h->values_stack++; - Assert(h->values_stack < MAX_SET_VALUES - 1); + ECCODES_ASSERT(h->values_stack < MAX_SET_VALUES - 1); h->values[stack] = args; h->values_count[stack] = count; @@ -1878,13 +1878,13 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest) { grib_accessor* act = grib_find_accessor(h, name); - Assert(act); + ECCODES_ASSERT(act); return act->nearest_smaller_value(val, nearest); } void grib_print_values(const char* title, const grib_values* values, FILE* out, int count) { - Assert(values); + ECCODES_ASSERT(values); for (int i = 0; i < count; ++i) { const grib_values aVal = values[i]; fprintf(out, "%s: %s=", title, aVal.name); diff --git a/src/grib_vdarray.cc b/src/grib_vdarray.cc index c2fba2c03..d4871105e 100644 --- a/src/grib_vdarray.cc +++ b/src/grib_vdarray.cc @@ -15,7 +15,7 @@ void grib_vdarray_print(const char* title, const grib_vdarray* vdarray) { size_t i = 0; char text[100] = {0,}; - Assert(vdarray); + ECCODES_ASSERT(vdarray); printf("%s: vdarray.n=%zu\n", title, vdarray->n); for (i = 0; i < vdarray->n; i++) { snprintf(text, sizeof(text), " vdarray->v[%zu]", i); diff --git a/src/grib_viarray.cc b/src/grib_viarray.cc index 54963366e..3b3da7972 100644 --- a/src/grib_viarray.cc +++ b/src/grib_viarray.cc @@ -16,7 +16,7 @@ void grib_viarray_print(const char* title, const grib_viarray* viarray) size_t i; char text[100] = {0,}; const size_t textLen = sizeof(text); - Assert(viarray); + ECCODES_ASSERT(viarray); printf("%s: viarray.n=%zu\n", title, viarray->n); for (i = 0; i < viarray->n; i++) { snprintf(text, textLen, " viarray->v[%zu]", i); diff --git a/src/md5.cc b/src/md5.cc index 3231be905..d22241a90 100644 --- a/src/md5.cc +++ b/src/md5.cc @@ -163,7 +163,7 @@ static void grib_md5_flush(grib_md5_state* s) void grib_md5_init(grib_md5_state* s) { - Assert(sizeof(uint64_t) == 8); + ECCODES_ASSERT(sizeof(uint64_t) == 8); memset(s, 0, sizeof(grib_md5_state)); s->h0 = 0x67452301; s->h1 = 0xefcdab89; diff --git a/src/string_util.cc b/src/string_util.cc index b2faa3674..c3c0c6d36 100644 --- a/src/string_util.cc +++ b/src/string_util.cc @@ -106,16 +106,16 @@ char** string_split(char* inputString, const char* delimiter) ++numTokens; // terminating NULL string to mark the end result = (char**)malloc(numTokens * sizeof(char*)); - Assert(result); + ECCODES_ASSERT(result); // Start tokenizing aToken = strtok_r(inputString, delimiter, &lasts); while (aToken) { - Assert(index < numTokens); + ECCODES_ASSERT(index < numTokens); *(result + index++) = strdup(aToken); aToken = strtok_r(NULL, delimiter, &lasts); } - Assert(index == numTokens - 1); + ECCODES_ASSERT(index == numTokens - 1); *(result + index) = NULL; return result; diff --git a/tests/bits.cc b/tests/bits.cc index f44583af7..6d53cd24c 100644 --- a/tests/bits.cc +++ b/tests/bits.cc @@ -39,7 +39,7 @@ void test_bits(double x, unsigned long mode) if (!(mode & NO_NEAREST_SMALLER_IBM_FLOAT)) { err = grib_nearest_smaller_ibm_float(x, &t); - Assert(!err); + ECCODES_ASSERT(!err); l = grib_ibm_to_long(y); dt = t - x; } diff --git a/tests/bufr_check_descriptors.cc b/tests/bufr_check_descriptors.cc index eec3a14eb..536413798 100644 --- a/tests/bufr_check_descriptors.cc +++ b/tests/bufr_check_descriptors.cc @@ -46,15 +46,15 @@ int main(int argc, char** argv) const size_t maxlen_keyName = sizeof(v.shortName); const size_t maxlen_units = sizeof(v.units); - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); filename = argv[1]; fp = fopen(filename, "r"); - Assert(fp); + ECCODES_ASSERT(fp); while (fgets(line, sizeof(line) - 1, fp)) { ++line_number; - Assert(strlen(line) > 0); + ECCODES_ASSERT(strlen(line) > 0); if (line[0] == '#') continue; /* Ignore first line with column titles */ list = string_split(line, "|"); if (!list) { diff --git a/tests/bufr_encode_pthreads.cc b/tests/bufr_encode_pthreads.cc index 8ca7aecff..5ffda423d 100644 --- a/tests/bufr_encode_pthreads.cc +++ b/tests/bufr_encode_pthreads.cc @@ -35,13 +35,13 @@ static int encode_file(char* template_file, char* output_file) int err = 0; long numSubsets = 0; - Assert(template_file); + ECCODES_ASSERT(template_file); in = fopen(template_file, "rb"); - Assert(in); + ECCODES_ASSERT(in); if (opt_write) { - Assert(output_file); + ECCODES_ASSERT(output_file); out = fopen(output_file, "wb"); - Assert(out); + ECCODES_ASSERT(out); } /* loop over the messages in the source BUFR and clone them */ @@ -50,7 +50,7 @@ static int encode_file(char* template_file, char* output_file) if (opt_clone) { h = codes_handle_clone(source_handle); - Assert(h); + ECCODES_ASSERT(h); } CODES_CHECK(codes_get_long(h, "numberOfSubsets", &numSubsets), 0); @@ -70,7 +70,7 @@ static int encode_file(char* template_file, char* output_file) unsigned long dump_flags = CODES_DUMP_FLAG_ALL_DATA; /* codes_dump_content(source_handle,devnull, "json", 1024, NULL); */ /* JSON dump with all attributes */ dumper = grib_dump_content_with_dumper(source_handle, dumper, devnull, dumper_name, dump_flags, NULL); - Assert(dumper); + ECCODES_ASSERT(dumper); fclose(devnull); } diff --git a/tests/codes_codetable.cc b/tests/codes_codetable.cc index 0d4878d00..e6af0cc5b 100644 --- a/tests/codes_codetable.cc +++ b/tests/codes_codetable.cc @@ -15,63 +15,63 @@ int main(int argc, char* argv[]) { - Assert(argc == 1); + ECCODES_ASSERT(argc == 1); grib_handle* h = grib_handle_new_from_samples(0, "GRIB2"); code_table_entry* entries = NULL; size_t num_entries = 0; int err = codes_codetable_get_contents_malloc(h, "indicatorOfUnitOfTimeRange", &entries, &num_entries); - Assert(!err); - Assert(entries != NULL); - Assert(num_entries == 256); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(entries != NULL); + ECCODES_ASSERT(num_entries == 256); for (size_t i=0; iproduct_kind); + ECCODES_ASSERT(h); + ECCODES_ASSERT(samples[i].expected_kind == h->product_kind); GRIB_CHECK(grib_get_string(h, "identifier", identifier, &len), 0); - Assert( strcmp(samples[i].expected_ID, identifier) == 0 ); + ECCODES_ASSERT( strcmp(samples[i].expected_ID, identifier) == 0 ); grib_handle_delete(h); } diff --git a/tests/codes_set_samples_path.cc b/tests/codes_set_samples_path.cc index 9204560d2..495c4b24e 100644 --- a/tests/codes_set_samples_path.cc +++ b/tests/codes_set_samples_path.cc @@ -28,7 +28,7 @@ int main(int argc, char** argv) grib_context* c = NULL; long paramId = 0; - Assert(argc == 3); + ECCODES_ASSERT(argc == 3); sample_name = argv[1]; new_dir = argv[2]; /* The directory containing the given sample */ @@ -38,7 +38,7 @@ int main(int argc, char** argv) /* Should fail - default samples path does not include ifs_samples dirs */ h = grib_handle_new_from_samples(c, sample_name); - Assert(!h); + ECCODES_ASSERT(!h); snprintf(full_path, 2048, "%s%c%s", new_dir, ECC_PATH_DELIMITER_CHAR, grib_samples_path(c)); printf("Change samples_path to: %s\n", full_path); @@ -47,9 +47,9 @@ int main(int argc, char** argv) codes_context_set_debug(c, 0); h = grib_handle_new_from_samples(c, sample_name); - Assert(h); + ECCODES_ASSERT(h); GRIB_CHECK(grib_get_long(h, "paramId", ¶mId), NULL); - Assert(paramId == 130); + ECCODES_ASSERT(paramId == 130); grib_handle_delete(h); printf("Success\n"); diff --git a/tests/grib_bpv_limit.cc b/tests/grib_bpv_limit.cc index 896e0cff7..948f57694 100644 --- a/tests/grib_bpv_limit.cc +++ b/tests/grib_bpv_limit.cc @@ -39,14 +39,14 @@ int main(int argc, char** argv) const double tolerance = 1e-5; size_t slong = sizeof(long) * 8; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); char* filename = argv[1]; for (i = 0; i < 255; i++) { FILE* in = fopen(filename, "rb"); - Assert(in); + ECCODES_ASSERT(in); grib_handle* h = grib_handle_new_from_file(0, in, &err); - Assert(h); + ECCODES_ASSERT(h); /* get the size of the values array*/ GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); diff --git a/tests/grib_check_param_concepts.cc b/tests/grib_check_param_concepts.cc index 319217546..1a299a4b5 100644 --- a/tests/grib_check_param_concepts.cc +++ b/tests/grib_check_param_concepts.cc @@ -26,7 +26,7 @@ static int type_of_surface_missing(const char* name, const char* value) /* Beware of problems where we put 'missing()' for a code table key! */ if (strncmp(value, "missing", 7) == 0) { fprintf(stderr, "Invalid value for %s Code Table entry: '%s'\n", name, value); - Assert(0); + ECCODES_ASSERT(0); } return 0; } @@ -60,7 +60,7 @@ static int grib_check_param_concepts(const char* key, const char* filename) count++; if (strlen(concept_value->name) == 0) { fprintf(stderr, "%s %s: Empty concept value (count=%d)\n", key, concept_value->name, count); - Assert(0); + ECCODES_ASSERT(0); } grib_concept_condition* concept_condition = concept_value->conditions; /* Convention: @@ -74,7 +74,7 @@ static int grib_check_param_concepts(const char* key, const char* filename) int err = 0; /* concept_value->name is the value of the key (e.g. 151163 or sst) */ if (strcmp(key, "cfVarName")==0) { - Assert( strlen(concept_value->name) > 0 ); + ECCODES_ASSERT( strlen(concept_value->name) > 0 ); if ( isdigit(concept_value->name[0]) || strcmp(concept_value->name, "~")==0 ) { fprintf(stderr, "%s %s: Invalid cfVarName in file %s\n", key, concept_value->name, filename); @@ -106,7 +106,7 @@ static int grib_check_param_concepts(const char* key, const char* filename) else { fprintf(stderr, "%s %s: Unknown class name: '%s'\n", key, concept_value->name, expression->class_name()); - Assert(0); + ECCODES_ASSERT(0); } if (!isLocal && strcmp(condition_name, "localTablesVersion") == 0) { fprintf(stderr, "%s %s: Cannot have localTablesVersion key in WMO file %s!\n", @@ -168,7 +168,7 @@ int main(int argc, char** argv) const char* concepts_key = argv[1]; const char* concepts_filename = argv[2]; - Assert(argc == 3); + ECCODES_ASSERT(argc == 3); err = grib_check_param_concepts(concepts_key, concepts_filename); if (err) return err; diff --git a/tests/grib_ecc-1431.cc b/tests/grib_ecc-1431.cc index 39454b203..7cb685fdf 100644 --- a/tests/grib_ecc-1431.cc +++ b/tests/grib_ecc-1431.cc @@ -64,7 +64,7 @@ int main(int argc, char** argv) for (const size_t in_values_len : values_lens) { for (const Range range : ranges) { - Assert(range.min < range.max); + ECCODES_ASSERT(range.min < range.max); std::cout << "Testing: " << "n_vals : " << std::setw(7) << in_values_len << " range(" << std::scientific << std::setw(12) << range.min << ", " << std::setw(12) << range.max << ") " @@ -97,26 +97,26 @@ int main(int argc, char** argv) //CODES_CHECK(codes_get_double_array(handle, "values", grid_simple_values, &grid_simple_values_len), 0); } - Assert(in_values_len == grid_simple_values_len); + ECCODES_ASSERT(in_values_len == grid_simple_values_len); // Test grid_ccsds packing_type = "grid_ccsds"; size = packing_type.size(); CODES_CHECK(codes_set_string(handle, "packingType", packing_type.c_str(), &size), 0); if ((err = codes_set_double_array(handle, "values", grid_simple_values, grid_simple_values_len)) != 0) { - Assert(!"CCSDS encoding failed"); + ECCODES_ASSERT(!"CCSDS encoding failed"); } if ((err = codes_get_double_array(handle, "values", grid_ccsds_values, &grid_ccsds_values_len)) != 0) { - Assert(!"CCSDS decoding failed"); + ECCODES_ASSERT(!"CCSDS decoding failed"); } - Assert(grid_ccsds_values_len == grid_simple_values_len); + ECCODES_ASSERT(grid_ccsds_values_len == grid_simple_values_len); // Test buffers for (size_t i = 0; i < grid_ccsds_values_len; ++i) { if (grid_ccsds_values[i] != grid_simple_values[i]) { std::cout.precision(dbl::max_digits10); std::cout << "Test failed: " << grid_ccsds_values[i] << " != " << grid_simple_values[i] << std::endl; - Assert(0); + ECCODES_ASSERT(0); } } diff --git a/tests/grib_ecc-1433.cc b/tests/grib_ecc-1433.cc index ed2ac04aa..d185c7ebe 100644 --- a/tests/grib_ecc-1433.cc +++ b/tests/grib_ecc-1433.cc @@ -50,7 +50,7 @@ int main(int argc, char** argv) grid_ccsds_values[i] > (values[i] / (1 + tolerance)))) { std::cout.precision(dbl::max_digits10); std::cout << "Test failed: " << grid_ccsds_values[i] << " != " << values[i] << std::endl; - Assert(0); + ECCODES_ASSERT(0); } } diff --git a/tests/grib_ecc-1467.cc b/tests/grib_ecc-1467.cc index 5c5e8e53b..74a4a2551 100644 --- a/tests/grib_ecc-1467.cc +++ b/tests/grib_ecc-1467.cc @@ -29,15 +29,15 @@ int main(int argc, char** argv) double dmin, dmax, dval; float fval; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); const char* filename = argv[1]; printf("Opening %s\n", filename); FILE* in = fopen(filename, "rb"); - Assert(in); + ECCODES_ASSERT(in); codes_handle* h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); - Assert(h); + ECCODES_ASSERT(h); CODES_CHECK(codes_get_float(h, "referenceValue", &fval), 0); CODES_CHECK(codes_get_double(h, "referenceValue", &dval), 0); @@ -55,7 +55,7 @@ int main(int argc, char** argv) if (abs_error > max_abs_error) { fprintf(stderr, "ERROR:\n\tfvalue %e\n\tdvalue %e\n\terror %e\n\tmax_abs_error %e\n", fvalues[i], dvalues[i], abs_error, max_abs_error); - Assert(!"Absolute error test failed\n"); + ECCODES_ASSERT(!"Absolute error test failed\n"); } dmin = dvalues[i] >= 0 ? dvalues[i] / (1 + tolerance) : dvalues[i] * (1 + tolerance); @@ -71,7 +71,7 @@ int main(int argc, char** argv) fprintf(stderr, "\tmax - fvalue = %.20e (%s)\n", dmax - fvalues[i], dmax - fvalues[i] >= 0 ? "OK" : "FAILED (should be positive)"); - Assert(!"Relative tolerance test failed\n"); + ECCODES_ASSERT(!"Relative tolerance test failed\n"); } } diff --git a/tests/grib_ecc-386.cc b/tests/grib_ecc-386.cc index 10f2adcdb..03beb93f2 100644 --- a/tests/grib_ecc-386.cc +++ b/tests/grib_ecc-386.cc @@ -29,12 +29,12 @@ int main(int argc, char** argv) if (argc < 2) return 1; in = fopen(argv[1], "rb"); - Assert(in); + ECCODES_ASSERT(in); /* create new handle */ err = 0; h = grib_handle_new_from_file(0, in, &err); - Assert(h); + ECCODES_ASSERT(h); /* get the size of the values array*/ GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); diff --git a/tests/grib_encode_pthreads.cc b/tests/grib_encode_pthreads.cc index 8bda99121..e4de7f194 100644 --- a/tests/grib_encode_pthreads.cc +++ b/tests/grib_encode_pthreads.cc @@ -57,8 +57,8 @@ static int encode_file(const char* input_file, const char* output_file) FILE* in = fopen(input_file, "rb"); FILE* out = fopen(output_file, "wb"); - Assert(in); - Assert(out); + ECCODES_ASSERT(in); + ECCODES_ASSERT(out); while ((source_handle = grib_handle_new_from_file(0, in, &err)) != NULL) { size_t size = 0, values_len = 0; @@ -68,7 +68,7 @@ static int encode_file(const char* input_file, const char* output_file) double d, e; grib_handle* clone_handle = grib_handle_clone(source_handle); - Assert(clone_handle); + ECCODES_ASSERT(clone_handle); GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len), 0); values = (double*)malloc(values_len * sizeof(double)); diff --git a/tests/grib_encode_pthreads2.cc b/tests/grib_encode_pthreads2.cc index 6ebe6438f..bb866e4b0 100644 --- a/tests/grib_encode_pthreads2.cc +++ b/tests/grib_encode_pthreads2.cc @@ -34,10 +34,10 @@ static int encode_file(const char* template_file, const char* output_file) double* values; in = fopen(template_file, "rb"); - Assert(in); + ECCODES_ASSERT(in); if (opt_write && output_file) { out = fopen(output_file, "wb"); - Assert(out); + ECCODES_ASSERT(out); } /* loop over the messages in the source GRIB and clone them */ @@ -49,7 +49,7 @@ static int encode_file(const char* template_file, const char* output_file) if (opt_clone) { h = grib_handle_clone(source_handle); - Assert(h); + ECCODES_ASSERT(h); } GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); diff --git a/tests/grib_geo_iter.cc b/tests/grib_geo_iter.cc index b9d23830f..15a638cc3 100644 --- a/tests/grib_geo_iter.cc +++ b/tests/grib_geo_iter.cc @@ -34,7 +34,7 @@ int main(int argc, char** argv) double* pValue = NULL; bool verbose = false; - Assert(argc == 3); + ECCODES_ASSERT(argc == 3); option = argv[1]; filename = argv[2]; if (strcmp(option, "-n")==0) { @@ -42,25 +42,25 @@ int main(int argc, char** argv) } fin = fopen(filename, "rb"); - Assert(fin); + ECCODES_ASSERT(fin); h = grib_handle_new_from_file(0, fin, &err); - Assert(!err); - Assert(h); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(h); GRIB_CHECK(grib_get_long(h,"numberOfDataPoints", &numberOfDataPoints),0); flags = (mode == NO_VALUES) ? GRIB_GEOITERATOR_NO_VALUES : 0; iter = grib_iterator_new(h, flags, &err); - Assert(!err); - Assert(iter); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(iter); - Assert(grib_iterator_has_next(iter)); + ECCODES_ASSERT(grib_iterator_has_next(iter)); n = 0; pValue = (mode == NO_VALUES) ? NULL : &value; while (grib_iterator_next(iter, &lat, &lon, pValue)) { if (n < numberOfDataPoints - 1) { - Assert(grib_iterator_has_next(iter)); + ECCODES_ASSERT(grib_iterator_has_next(iter)); } if (verbose) { printf("%9.3f %9.3f ",lat, lon); @@ -69,9 +69,9 @@ int main(int argc, char** argv) } n++; } - Assert(n == numberOfDataPoints); + ECCODES_ASSERT(n == numberOfDataPoints); - Assert(grib_iterator_has_next(iter) == 0); + ECCODES_ASSERT(grib_iterator_has_next(iter) == 0); { // Test getting the previous value from a geoiterator. @@ -82,10 +82,10 @@ int main(int argc, char** argv) if (strstr(gridType, "regular_")) { double last_lat = 0, last_lon = 0, last_value = 0; int result = grib_iterator_previous(iter, &last_lat, &last_lon, &last_value); - Assert(result == 1); - Assert(lat == last_lat); - Assert(lon == last_lon); - Assert(value == last_value); + ECCODES_ASSERT(result == 1); + ECCODES_ASSERT(lat == last_lat); + ECCODES_ASSERT(lon == last_lon); + ECCODES_ASSERT(value == last_value); } } diff --git a/tests/grib_ieee.cc b/tests/grib_ieee.cc index 1c1595548..26248dd8b 100644 --- a/tests/grib_ieee.cc +++ b/tests/grib_ieee.cc @@ -93,14 +93,14 @@ int main(int argc, char* argv[]) #if 1 unsigned long i = 0; printf("Test doubles with grib_ieee_to_long/grib_long_to_ieee...\n"); - Assert(test_doubles(grib_ieee_to_long, grib_long_to_ieee) == 1); + ECCODES_ASSERT(test_doubles(grib_ieee_to_long, grib_long_to_ieee) == 1); printf("Test doubles with grib_ieee64_to_long/grib_long_to_ieee64...\n"); - Assert(test_doubles(grib_ieee64_to_long, grib_long_to_ieee64) == 1); + ECCODES_ASSERT(test_doubles(grib_ieee64_to_long, grib_long_to_ieee64) == 1); printf("Test integers...\n"); /* test(3242539564, grib_ieee_to_long, grib_long_to_ieee); This fails! */ - Assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i); + ECCODES_ASSERT(grib_ieee_to_long(grib_long_to_ieee(i)) == i); /* The minimum value for which we can convert a long to ieee and back is 0x800000 */ /* The maximum value for which we can convert a long to ieee and back is 0x7f800000 */ @@ -109,8 +109,8 @@ int main(int argc, char* argv[]) if (grib_ieee_to_long(grib_long_to_ieee(i)) != i) { printf("i=%lu i=%lx e=%g x=%lx\n", i, i, grib_long_to_ieee(i), grib_ieee_to_long(grib_long_to_ieee(i))); - /*Assert(grib_ieee_to_long(grib_long_to_ieee(i)) == i);*/ - Assert(0); + /*ECCODES_ASSERT(grib_ieee_to_long(grib_long_to_ieee(i)) == i);*/ + ECCODES_ASSERT(0); } /*if(grib_ieee_to_long(grib_long_to_ieee(j)) != j) { @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) double c = p(ref1, ref1); double d = p(ref2, ref2); - Assert(min < max); + ECCODES_ASSERT(min < max); #endif printf("ALL DONE\n"); diff --git a/tests/grib_keys_iter.cc b/tests/grib_keys_iter.cc index 0e93fefde..145e2bdb8 100644 --- a/tests/grib_keys_iter.cc +++ b/tests/grib_keys_iter.cc @@ -20,9 +20,9 @@ int main(int argc, char* argv[]) grib_handle* h = NULL; int err = 0; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); FILE* f = fopen(argv[1], "rb"); - Assert(f); + ECCODES_ASSERT(f); while ((h = grib_handle_new_from_file(0, f, &err)) != NULL) { grib_keys_iterator* kiter = NULL; @@ -30,14 +30,14 @@ int main(int argc, char* argv[]) /* Use namespace of NULL to get ALL keys */ /* Set flags to 0 to not filter any keys */ kiter = grib_keys_iterator_new(h, /*flags=*/0, /*namespace=*/NULL); - Assert(kiter); + ECCODES_ASSERT(kiter); while (grib_keys_iterator_next(kiter)) { const char* name = grib_keys_iterator_get_name(kiter); - Assert(name); + ECCODES_ASSERT(name); int type = 0; GRIB_CHECK(grib_get_native_type(h, name, &type), 0); - Assert( type > 0 && type < 7 ); + ECCODES_ASSERT( type > 0 && type < 7 ); int ktype = grib_keys_iterator_get_native_type(kiter); if (type != ktype) { fprintf(stderr, "ERROR: key=%s type=%s ktype=%s\n", name, grib_get_type_name(type), grib_get_type_name(ktype)); @@ -54,30 +54,30 @@ int main(int argc, char* argv[]) char value[MAX_VAL_LEN] = {0,}; size_t vlen = MAX_VAL_LEN; GRIB_CHECK(grib_get_string(h, name, value, &vlen), name); - Assert( strlen(value) > 0 ); + ECCODES_ASSERT( strlen(value) > 0 ); int e = grib_keys_iterator_get_string(kiter, value, &vlen); - Assert(!e); - Assert( STR_EQUAL(name, value) ); + ECCODES_ASSERT(!e); + ECCODES_ASSERT( STR_EQUAL(name, value) ); } if (STR_EQUAL(name, "editionNumber")) { long lVal = 0; size_t llen = 1; int e = grib_keys_iterator_get_long(kiter, &lVal, &llen); - Assert(!e); - Assert(lVal == 1 || lVal == 2); - Assert(codes_key_is_computed(h, name, &e) == 0 && !e); + ECCODES_ASSERT(!e); + ECCODES_ASSERT(lVal == 1 || lVal == 2); + ECCODES_ASSERT(codes_key_is_computed(h, name, &e) == 0 && !e); } if (STR_EQUAL(name, "gridType")) { int e = 0; - Assert(codes_key_is_computed(h, name, &e) == 1 && !e); + ECCODES_ASSERT(codes_key_is_computed(h, name, &e) == 1 && !e); } if (STR_EQUAL(name, "longitudeOfLastGridPointInDegrees")) { int e = 0; - Assert(codes_key_is_computed(h, name, &e) == 1 && !e); + ECCODES_ASSERT(codes_key_is_computed(h, name, &e) == 1 && !e); } if (STR_EQUAL(name, "longitudeOfLastGridPoint")) { int e = 0; - Assert(codes_key_is_computed(h, name, &e) == 0 && !e); + ECCODES_ASSERT(codes_key_is_computed(h, name, &e) == 0 && !e); } } diff --git a/tests/grib_keys_iter_skip.cc b/tests/grib_keys_iter_skip.cc index 54d5d1c79..0d65f540c 100644 --- a/tests/grib_keys_iter_skip.cc +++ b/tests/grib_keys_iter_skip.cc @@ -18,10 +18,10 @@ int main(int argc, char* argv[]) grib_handle* h = NULL; int err = 0; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); const char* fname = argv[1]; FILE* f = fopen(fname, "rb"); - Assert(f); + ECCODES_ASSERT(f); unsigned long flags[] = { GRIB_KEYS_ITERATOR_SKIP_READ_ONLY, @@ -39,12 +39,12 @@ int main(int argc, char* argv[]) for (unsigned long i=0; i 0); + ECCODES_ASSERT(name); + ECCODES_ASSERT(strlen(name) > 0); ++count; } grib_keys_iterator_delete(kiter); diff --git a/tests/grib_local_MeteoFrance.cc b/tests/grib_local_MeteoFrance.cc index 9052308a7..3559383aa 100644 --- a/tests/grib_local_MeteoFrance.cc +++ b/tests/grib_local_MeteoFrance.cc @@ -849,7 +849,7 @@ int main(int argc, char* argv[]) size_t len = 0; const char* outfile; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); outfile = argv[1]; GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "regular_ll_pl_grib2")) == NULL), 0); diff --git a/tests/grib_multi_from_message.cc b/tests/grib_multi_from_message.cc index 1728e371c..1513bf13f 100644 --- a/tests/grib_multi_from_message.cc +++ b/tests/grib_multi_from_message.cc @@ -40,16 +40,16 @@ int main(int argc, char* argv[]) else return 1; - Assert(filename); + ECCODES_ASSERT(filename); f = fopen(filename, "rb"); - Assert(f); + ECCODES_ASSERT(f); stat(filename, &finfo); fsize = finfo.st_size; data = (unsigned char*)malloc(fsize); p = data; - Assert(data); + ECCODES_ASSERT(data); if (fread(data, 1, fsize, f) != fsize) { perror(filename); diff --git a/tests/grib_packing_order.cc b/tests/grib_packing_order.cc index 89a96ff61..1267ef1e3 100644 --- a/tests/grib_packing_order.cc +++ b/tests/grib_packing_order.cc @@ -24818,7 +24818,7 @@ int main(int argc, char** argv) fprintf(stderr, "Using sample_filename = %s\n", sample_filename); h = grib_handle_new_from_samples(0, sample_filename); - Assert(h); + ECCODES_ASSERT(h); if (strcmp(packing_type, "grid_second_order") == 0 && packing_stage == VALUES_BEFORE_PACKING_TYPE) { check = 0; /* TDOD */ @@ -24861,7 +24861,7 @@ int main(int argc, char** argv) GRIB_CHECK(grib_get_long(h, "offsetBeforeData", &offsetBeforeData), 0); calc = (offsetAfterData - offsetBeforeData) * 8.0 / values_len; printf("bitsPerValue calculated as = (offsetAfterData - offsetBeforeData)*8/numValues = %g\n", calc); - Assert(calc == 16 || calc == 32 || calc == 64); + ECCODES_ASSERT(calc == 16 || calc == 32 || calc == 64); } free(vals); } diff --git a/tests/grib_partial_message.cc b/tests/grib_partial_message.cc index 954d93bc6..a6dc2acd9 100644 --- a/tests/grib_partial_message.cc +++ b/tests/grib_partial_message.cc @@ -22,24 +22,24 @@ int main(int argc, char** argv) size_t size1 = 0; grib_handle* h_partial = 0; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); infilename = argv[1]; printf("Processing file %s\n", infilename); in = fopen(infilename, "rb"); - Assert(in); + ECCODES_ASSERT(in); h_full = grib_handle_new_from_file(0, in, &err); - Assert(h_full); - Assert(!err); + ECCODES_ASSERT(h_full); + ECCODES_ASSERT(!err); GRIB_CHECK(grib_get_message_headers(h_full, &msg1, &size1), 0); h_partial = grib_handle_new_from_partial_message(h_full->context, msg1, size1); - Assert(h_partial); + ECCODES_ASSERT(h_partial); iter = grib_keys_iterator_new(h_partial, GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL); - Assert(iter); + ECCODES_ASSERT(iter); while (grib_keys_iterator_next(iter)) { name = grib_keys_iterator_get_name(iter); diff --git a/tests/grib_set_bytes.cc b/tests/grib_set_bytes.cc index 6fc7e434b..c579bf3f6 100644 --- a/tests/grib_set_bytes.cc +++ b/tests/grib_set_bytes.cc @@ -48,22 +48,22 @@ int main(int argc, char** argv) size_t uuid_long_len = sizeof (uuid_long); in = fopen(infile, "rb"); - Assert(in); + ECCODES_ASSERT(in); out = fopen(outfile, "wb"); - Assert(out); + ECCODES_ASSERT(out); h = grib_handle_new_from_file(0, in, &err); - Assert(h); + ECCODES_ASSERT(h); /* The uuidOfVGrid key is 16 bytes long */ err = grib_set_bytes(h, "uuidOfVGrid", uuid_short, &uuid_short_len); - Assert(err == GRIB_BUFFER_TOO_SMALL); + ECCODES_ASSERT(err == GRIB_BUFFER_TOO_SMALL); err = grib_set_bytes(h, "uuidOfVGrid", uuid_long, &uuid_long_len); - Assert(err == GRIB_BUFFER_TOO_SMALL); + ECCODES_ASSERT(err == GRIB_BUFFER_TOO_SMALL); /* This one should work */ err = grib_set_bytes(h, "uuidOfVGrid", uuid_good, &uuid_good_len); - Assert(err == 0); + ECCODES_ASSERT(err == 0); GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); if (fwrite(buffer, 1, size, out) != size) { diff --git a/tests/grib_set_force.cc b/tests/grib_set_force.cc index fdc9b4694..39a3ad215 100644 --- a/tests/grib_set_force.cc +++ b/tests/grib_set_force.cc @@ -153,16 +153,16 @@ int main(int argc, char** argv) const void* buffer = NULL; const char* mode = NULL; - Assert(argc == 4); + ECCODES_ASSERT(argc == 4); mode = argv[1]; /*all_values or coded_values*/ infile = argv[2]; outfile = argv[3]; in = fopen(infile, "rb"); - Assert(in); + ECCODES_ASSERT(in); out = fopen(outfile, "wb"); - Assert(out); + ECCODES_ASSERT(out); while ((h = grib_handle_new_from_file(NULL, in, &err)) != NULL || err != GRIB_SUCCESS) { long numberOfDataPoints = 0; @@ -172,7 +172,7 @@ int main(int argc, char** argv) double missing = 9999; const size_t num_all_vals = sizeof(values) / sizeof(values[0]); - Assert(num_all_vals == numberOfDataPoints); /*Sanity check*/ + ECCODES_ASSERT(num_all_vals == numberOfDataPoints); /*Sanity check*/ GRIB_CHECK(grib_set_long(h, "bitmapPresent", 1), 0); GRIB_CHECK(grib_set_double(h, "missingValue", missing), 0); printf("Fully specified: %zu values\n", num_all_vals); @@ -180,8 +180,8 @@ int main(int argc, char** argv) } else { const size_t num_coded_vals = sizeof(codedValues) / sizeof(codedValues[0]); - Assert(strcmp(mode, "coded_values") == 0); - Assert(num_coded_vals < numberOfDataPoints); /*Sanity check*/ + ECCODES_ASSERT(strcmp(mode, "coded_values") == 0); + ECCODES_ASSERT(num_coded_vals < numberOfDataPoints); /*Sanity check*/ printf("Partially specified: %zu values\n", num_coded_vals); GRIB_CHECK(grib_set_force_double_array(h, "codedValues", codedValues, num_coded_vals), 0); } diff --git a/tests/grib_sh_imag.cc b/tests/grib_sh_imag.cc index 4d6b7540b..eb051b786 100644 --- a/tests/grib_sh_imag.cc +++ b/tests/grib_sh_imag.cc @@ -29,7 +29,7 @@ int main(int argc, char* argv[]) int m, n, k; const char* outfile; - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); outfile = argv[1]; GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "sh_ml_grib2")) == NULL), 0); diff --git a/tests/grib_spectral.cc b/tests/grib_spectral.cc index 78db8da4d..75a59950a 100644 --- a/tests/grib_spectral.cc +++ b/tests/grib_spectral.cc @@ -31,21 +31,21 @@ int main(int argc, char* argv[]) char packingType[50] = {0,}; bool do_compare = true; - Assert(argc == 3); + ECCODES_ASSERT(argc == 3); in_filename = argv[1]; out_filename = argv[2]; printf("Opening file '%s'...\n", in_filename); fin = fopen(in_filename, "rb"); - Assert(fin); + ECCODES_ASSERT(fin); h = grib_handle_new_from_file(0, fin, &err); - Assert(h); - Assert(!err); + ECCODES_ASSERT(h); + ECCODES_ASSERT(!err); len = sizeof(packingType); GRIB_CHECK(grib_get_string(h, "packingType", packingType, &len), 0); - Assert( STR_EQUAL(packingType, "spectral_complex") || STR_EQUAL(packingType, "spectral_simple") ); + ECCODES_ASSERT( STR_EQUAL(packingType, "spectral_complex") || STR_EQUAL(packingType, "spectral_simple") ); GRIB_CHECK(grib_set_long(h, "pentagonalResolutionParameterJ", MTRONC), 0); GRIB_CHECK(grib_set_long(h, "pentagonalResolutionParameterK", MTRONC), 0); @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) fout = fopen(out_filename, "wb"); GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); if (fwrite(buffer, 1, size, fout) != size) { - Assert(!"Failed to write data"); + ECCODES_ASSERT(!"Failed to write data"); } fclose(fout); @@ -104,8 +104,8 @@ int main(int argc, char* argv[]) // Read in the saved GRIB file if (do_compare) { printf("Load values from saved file and compare....\n"); - fin = fopen(out_filename, "rb"); Assert(fin); - h = grib_handle_new_from_file(0, fin, &err); Assert(h); + fin = fopen(out_filename, "rb"); ECCODES_ASSERT(fin); + h = grib_handle_new_from_file(0, fin, &err); ECCODES_ASSERT(h); GRIB_CHECK(grib_get_double_array(h, "values", zval, &len), 0); for (i = 0; i < ILCHAM; ++i) { const double diff = fabs(zval[i] - values[i]); diff --git a/tests/grib_unpack_subarray.cc b/tests/grib_unpack_subarray.cc index 1a7bfadab..073aa3aab 100644 --- a/tests/grib_unpack_subarray.cc +++ b/tests/grib_unpack_subarray.cc @@ -12,7 +12,7 @@ int main(int argc, char** argv) { - Assert(argc == 2); + ECCODES_ASSERT(argc == 2); int err = 0; size_t nvalues = 0; @@ -20,18 +20,18 @@ int main(int argc, char** argv) grib_context* c = grib_context_get_default(); FILE* fin = fopen(filename, "r"); - Assert(fin); + ECCODES_ASSERT(fin); grib_handle* h = grib_handle_new_from_file(0, fin, &err); - Assert(h); - Assert(!err); + ECCODES_ASSERT(h); + ECCODES_ASSERT(!err); grib_accessor* a = grib_find_accessor(h, "codedValues"); - Assert(a); + ECCODES_ASSERT(a); GRIB_CHECK(grib_get_size(h, "codedValues", &nvalues), 0); double* all_values = (double*)grib_context_malloc(c, sizeof(double) * nvalues); double* sub_values = (double*)grib_context_malloc(c, sizeof(double) * nvalues); - Assert(all_values); - Assert(sub_values); + ECCODES_ASSERT(all_values); + ECCODES_ASSERT(sub_values); size_t len = nvalues; GRIB_CHECK(a->unpack_double(all_values, &len), 0); @@ -42,7 +42,7 @@ int main(int argc, char** argv) GRIB_CHECK(a->unpack_double_subarray(sub_values, start, len), 0); for (size_t i = 0; i < len; ++i) { //printf("sub[%zu]=%.10e\n", start + i, sub_values[i]); - Assert(all_values[start+i] == sub_values[i]); + ECCODES_ASSERT(all_values[start+i] == sub_values[i]); } grib_context_free(c, all_values); diff --git a/tests/grib_update_sections_lengths.cc b/tests/grib_update_sections_lengths.cc index cda520643..2118214e4 100644 --- a/tests/grib_update_sections_lengths.cc +++ b/tests/grib_update_sections_lengths.cc @@ -27,10 +27,10 @@ int main(int argc, char* argv[]) oufile = argv[2]; inf = fopen(infile, "rb"); - Assert(inf); + ECCODES_ASSERT(inf); ouf = fopen(oufile, "wb"); - Assert(ouf); + ECCODES_ASSERT(ouf); while ((h = grib_handle_new_from_file(0, inf, &err)) != NULL) { grib_update_sections_lengths(h); diff --git a/tests/grib_util_set_spec.cc b/tests/grib_util_set_spec.cc index 095eb7135..89583fd68 100644 --- a/tests/grib_util_set_spec.cc +++ b/tests/grib_util_set_spec.cc @@ -30,7 +30,7 @@ static int get_packing_type_code(const char* packingType) else if (STR_EQUAL(packingType, "grid_complex")) return GRIB_UTIL_PACKING_TYPE_GRID_COMPLEX; - Assert(!"Invalid packingType"); + ECCODES_ASSERT(!"Invalid packingType"); return result; } @@ -53,20 +53,20 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; - Assert(input_filename); + ECCODES_ASSERT(input_filename); in = fopen(input_filename, "rb"); - Assert(in); + ECCODES_ASSERT(in); handle = grib_handle_new_from_file(0, in, &err); - Assert(handle); + ECCODES_ASSERT(handle); CODES_CHECK(grib_get_string(handle, "gridType", gridType, &slen), 0); if (!STR_EQUAL(gridType, "reduced_gg")) { grib_handle_delete(handle); return; } - Assert(output_filename); + ECCODES_ASSERT(output_filename); out = fopen(output_filename, "wb"); - Assert(out); + ECCODES_ASSERT(out); CODES_CHECK(grib_get_size(handle, "values", &inlen), 0); values = (double*)malloc(sizeof(double) * inlen); @@ -114,29 +114,29 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi values, outlen, &err); - Assert(finalh); - Assert(err == 0); + ECCODES_ASSERT(finalh); + ECCODES_ASSERT(err == 0); /* Try some invalid inputs and check it is handled */ { grib_handle* h2 = 0; packing_spec.accuracy = 999; h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == GRIB_INTERNAL_ERROR); - Assert(!h2); + ECCODES_ASSERT(err == GRIB_INTERNAL_ERROR); + ECCODES_ASSERT(!h2); if (h2) exit(1); #ifdef INFINITY packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; values[0] = INFINITY; h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == GRIB_ENCODING_ERROR); - Assert(!h2); + ECCODES_ASSERT(err == GRIB_ENCODING_ERROR); + ECCODES_ASSERT(!h2); if (h2) exit(1); values[0] = -INFINITY; h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == GRIB_ENCODING_ERROR); - Assert(!h2); + ECCODES_ASSERT(err == GRIB_ENCODING_ERROR); + ECCODES_ASSERT(!h2); if (h2) exit(1); #endif } @@ -146,7 +146,7 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_GRIB), 0); CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_GRIB), 0); if (fwrite(buffer, 1, size, out) != size) { - Assert(0); + ECCODES_ASSERT(0); } grib_handle_delete(handle); grib_handle_delete(finalh); @@ -176,11 +176,11 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; - Assert(input_filename); + ECCODES_ASSERT(input_filename); in = fopen(input_filename, "rb"); - Assert(in); + ECCODES_ASSERT(in); handle = grib_handle_new_from_file(0, in, &err); - Assert(handle); + ECCODES_ASSERT(handle); CODES_CHECK(grib_get_long(handle, "edition", &input_edition), 0); @@ -189,9 +189,9 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi grib_handle_delete(handle); return; } - Assert(output_filename); + ECCODES_ASSERT(output_filename); out = fopen(output_filename, "wb"); - Assert(out); + ECCODES_ASSERT(out); CODES_CHECK(grib_get_size(handle, "values", &inlen), 0); values = (double*)malloc(sizeof(double) * inlen); @@ -242,8 +242,8 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi values, outlen, &err); - Assert(finalh); - Assert(err == 0); + ECCODES_ASSERT(finalh); + ECCODES_ASSERT(err == 0); /* Check expand_bounding_box worked. * Specified latitudeOfFirstGridPointInDegrees cannot be encoded in GRIB1 @@ -252,7 +252,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi const double expected_lat1 = 60.001; double lat1 = 0; CODES_CHECK(grib_get_double(finalh, "latitudeOfFirstGridPointInDegrees", &lat1), 0); - Assert(fabs(lat1 - expected_lat1) < 1e-10); + ECCODES_ASSERT(fabs(lat1 - expected_lat1) < 1e-10); } /* Write out the message to the output file */ @@ -260,7 +260,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_GRIB), 0); CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_GRIB), 0); if (fwrite(buffer, 1, size, out) != size) { - Assert(0); + ECCODES_ASSERT(0); } grib_handle_delete(handle); grib_handle_delete(finalh); @@ -290,15 +290,15 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi grib_util_grid_spec spec={0,}; grib_util_packing_spec packing_spec={0,}; - in = fopen(input_filename,"rb"); Assert(in); - handle = grib_handle_new_from_file(0, in, &err); Assert(handle); + in = fopen(input_filename,"rb"); ECCODES_ASSERT(in); + handle = grib_handle_new_from_file(0, in, &err); ECCODES_ASSERT(handle); CODES_CHECK(grib_get_string(handle, "packingType", gridType, &slen),0); if (!STR_EQUAL(gridType, "grid_complex_spatial_differencing")) { grib_handle_delete(handle); return; } - out = fopen(output_filename,"wb"); Assert(out); + out = fopen(output_filename,"wb"); ECCODES_ASSERT(out); CODES_CHECK(grib_get_size(handle,"values",&inlen), 0); values = (double*)malloc(sizeof(double)*inlen); @@ -342,13 +342,13 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi values, outlen, &err); - Assert(finalh); - Assert(err == 0); + ECCODES_ASSERT(finalh); + ECCODES_ASSERT(err == 0); /* Write out the message to the output file */ CODES_CHECK(grib_get_message(finalh, &buffer, &size),0); if(fwrite(buffer,1,size,out) != size) { - Assert(0); + ECCODES_ASSERT(0); } grib_handle_delete(handle); grib_handle_delete(finalh); diff --git a/tests/grib_util_set_spec2.cc b/tests/grib_util_set_spec2.cc index ddd3f1dc5..66be1f868 100644 --- a/tests/grib_util_set_spec2.cc +++ b/tests/grib_util_set_spec2.cc @@ -41,7 +41,7 @@ static grib_handle* test0() grib_handle* finalh = codes_grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -63,7 +63,7 @@ static grib_handle* test1() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -89,7 +89,7 @@ static grib_handle* test2() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -117,7 +117,7 @@ static grib_handle* test3() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -145,7 +145,7 @@ static grib_handle* test4() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -168,7 +168,7 @@ static grib_handle* test5() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -191,7 +191,7 @@ static grib_handle* test6() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -212,7 +212,7 @@ static grib_handle* test7() grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); - Assert(err == 0); + ECCODES_ASSERT(err == 0); return finalh; } @@ -226,7 +226,7 @@ int main() const size_t num_tests = sizeof(funcs)/sizeof(funcs[0]); for (size_t i = 0; i < num_tests; i++) { grib_handle* result = funcs[i](); - Assert(result); + ECCODES_ASSERT(result); dump_it(result); } return 0; diff --git a/tests/ibm.cc b/tests/ibm.cc index d7a5050c8..3abfa6eb0 100644 --- a/tests/ibm.cc +++ b/tests/ibm.cc @@ -16,15 +16,15 @@ int main(int argc, char* argv[]) { unsigned long i = 0; - Assert(grib_ibm_to_long(grib_long_to_ibm(i)) == i); + ECCODES_ASSERT(grib_ibm_to_long(grib_long_to_ibm(i)) == i); for (i = 1; i < 0x7fffffff; i++) { unsigned long j = i | 0x80000000; if (grib_ibm_to_long(grib_long_to_ibm(i)) != i) { printf("i=%ld i=%lx e=%g x=%lx\n", i, i, grib_long_to_ibm(i), grib_ibm_to_long(grib_long_to_ibm(i))); - Assert(grib_ibm_to_long(grib_long_to_ibm(i)) == i); + ECCODES_ASSERT(grib_ibm_to_long(grib_long_to_ibm(i)) == i); } - Assert(grib_ibm_to_long(grib_long_to_ibm(j)) == j); + ECCODES_ASSERT(grib_ibm_to_long(grib_long_to_ibm(j)) == j); if ((i % 100000) == 0) printf("i = %08lx %08lx %g %g\n", i, j, grib_long_to_ibm(i), grib_long_to_ibm(j)); } diff --git a/tests/julian.cc b/tests/julian.cc index 559d9883a..6dd5a16cd 100644 --- a/tests/julian.cc +++ b/tests/julian.cc @@ -71,16 +71,16 @@ static void Test0() sec = 24; codes_datetime_to_julian(year, month, day, hour, min, sec, &jd); - Assert(DBL_EQUAL(jd, 2378891.268333)); + ECCODES_ASSERT(DBL_EQUAL(jd, 2378891.268333)); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); grib_julian_to_datetime(jd, &year, &month, &day, &hour, &min, &sec); - Assert(year == 1801); - Assert(month == 1); - Assert(day == 30); - Assert(hour == 18); - Assert(min == 26); - Assert(sec == 24); + ECCODES_ASSERT(year == 1801); + ECCODES_ASSERT(month == 1); + ECCODES_ASSERT(day == 30); + ECCODES_ASSERT(hour == 18); + ECCODES_ASSERT(min == 26); + ECCODES_ASSERT(sec == 24); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); } @@ -99,16 +99,16 @@ static void Test1() sec = 24; grib_datetime_to_julian(year, month, day, hour, min, sec, &jd); - Assert(DBL_EQUAL(jd, 2436116.31)); + ECCODES_ASSERT(DBL_EQUAL(jd, 2436116.31)); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); grib_julian_to_datetime(jd, &year, &month, &day, &hour, &min, &sec); - Assert(year == 1957); - Assert(month == 10); - Assert(day == 4); - Assert(hour == 19); - Assert(min == 26); - Assert(sec == 24); + ECCODES_ASSERT(year == 1957); + ECCODES_ASSERT(month == 10); + ECCODES_ASSERT(day == 4); + ECCODES_ASSERT(hour == 19); + ECCODES_ASSERT(min == 26); + ECCODES_ASSERT(sec == 24); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); } @@ -146,7 +146,7 @@ static void Test2() if (!DBL_EQUAL(jd, jds[i])) { fprintf(stderr, "i=%d: Got: %f, expected: %f\n", i, jd, jds[i]); - Assert(0); + ECCODES_ASSERT(0); } jdl = (long)(jd + 0.5); @@ -226,7 +226,7 @@ static void Test5() codes_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1); if (Check(year, month, day, hour, min, sec, year1, month1, day1, hour1, min1, sec1)) { - Assert(!"Bad input should have failed checks"); + ECCODES_ASSERT(!"Bad input should have failed checks"); } } diff --git a/tests/unit_tests.cc b/tests/unit_tests.cc index e60f4b4f6..2a4d56d29 100644 --- a/tests/unit_tests.cc +++ b/tests/unit_tests.cc @@ -24,7 +24,7 @@ typedef enum static void compare_doubles(const double d1, const double d2, const double epsilon) { - Assert(fabs(d1 - d2) < epsilon); + ECCODES_ASSERT(fabs(d1 - d2) < epsilon); } static void check_float_representation(const double val, const double expected, const FloatRep rep) @@ -32,9 +32,9 @@ static void check_float_representation(const double val, const double expected, double out = 0; const double tolerance = 1e-9; if (rep == IBM_FLOAT) - Assert(grib_nearest_smaller_ibm_float(val, &out) == GRIB_SUCCESS); + ECCODES_ASSERT(grib_nearest_smaller_ibm_float(val, &out) == GRIB_SUCCESS); else - Assert(grib_nearest_smaller_ieee_float(val, &out) == GRIB_SUCCESS); + ECCODES_ASSERT(grib_nearest_smaller_ieee_float(val, &out) == GRIB_SUCCESS); /*printf("%s: d1=%10.20f, out=%10.20f\n", (rep==IBM_FLOAT)?"ibm":"ieee", val, out);*/ @@ -46,8 +46,8 @@ static void test_get_package_name() printf("Running %s ...\n", __func__); const char* pn = codes_get_package_name(); - Assert(pn != NULL); - Assert(strlen(pn) > 1); + ECCODES_ASSERT(pn != NULL); + ECCODES_ASSERT(strlen(pn) > 1); printf("Package name = %s\n", pn); } @@ -56,7 +56,7 @@ static void test_get_git_sha1() printf("Running %s ...\n", __func__); const char* sha1 = codes_get_git_sha1(); - Assert(sha1 != NULL); + ECCODES_ASSERT(sha1 != NULL); printf("Git SHA1 = %s\n", sha1); } @@ -65,9 +65,9 @@ static void test_get_build_date() printf("Running %s ...\n", __func__); const char* bdate = codes_get_build_date(); - Assert(bdate != NULL); + ECCODES_ASSERT(bdate != NULL); /* Should be of the format YYYY.MM.DD or empty (not implemented) */ - Assert( strlen(bdate) == 0 || isdigit(bdate[0]) ); + ECCODES_ASSERT( strlen(bdate) == 0 || isdigit(bdate[0]) ); } static void test_grib_nearest_smaller_ibmfloat() @@ -104,7 +104,7 @@ static void test_gaussian_latitudes(int order) double* lats = (double*)malloc(sizeof(double) * num); ret = codes_get_gaussian_latitudes(order, lats); - Assert(ret == GRIB_SUCCESS); + ECCODES_ASSERT(ret == GRIB_SUCCESS); lat1 = lats[0]; lat2 = lats[num - 1]; @@ -141,7 +141,7 @@ static void test_gaussian_latitude_640() const double tolerance = 1e-6; double* lats = (double*)malloc(sizeof(double) * num); ret = codes_get_gaussian_latitudes(order, lats); - Assert(ret == GRIB_SUCCESS); + ECCODES_ASSERT(ret == GRIB_SUCCESS); compare_doubles(lats[0], 89.892396, tolerance); compare_doubles(lats[1], 89.753005, tolerance); @@ -191,35 +191,35 @@ static void test_string_splitting() char** list = 0; list = string_split(input, "|"); - if (!list) { Assert(!"List is NULL"); return; } + if (!list) { ECCODES_ASSERT(!"List is NULL"); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - Assert(i == 4); - if (!list[0] || !STR_EQUAL(list[0], "Born")) Assert(0); - if (!list[1] || !STR_EQUAL(list[1], "To")) Assert(0); - if (!list[2] || !STR_EQUAL(list[2], "Be")) Assert(0); - if (!list[3] || !STR_EQUAL(list[3], "Wild")) Assert(0); - Assert(list[4] == NULL); + ECCODES_ASSERT(i == 4); + if (!list[0] || !STR_EQUAL(list[0], "Born")) ECCODES_ASSERT(0); + if (!list[1] || !STR_EQUAL(list[1], "To")) ECCODES_ASSERT(0); + if (!list[2] || !STR_EQUAL(list[2], "Be")) ECCODES_ASSERT(0); + if (!list[3] || !STR_EQUAL(list[3], "Wild")) ECCODES_ASSERT(0); + ECCODES_ASSERT(list[4] == NULL); for (i = 0; list[i] != NULL; ++i) free(list[i]); free(list); strcpy(input, "12345|a gap|"); list = string_split(input, "|"); - if (!list) { Assert(0); return; } + if (!list) { ECCODES_ASSERT(0); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - Assert(i == 2); - if (!list[0] || !STR_EQUAL(list[0], "12345")) Assert(0); - if (!list[1] || !STR_EQUAL(list[1], "a gap")) Assert(0); - Assert(list[2] == NULL); + ECCODES_ASSERT(i == 2); + if (!list[0] || !STR_EQUAL(list[0], "12345")) ECCODES_ASSERT(0); + if (!list[1] || !STR_EQUAL(list[1], "a gap")) ECCODES_ASSERT(0); + ECCODES_ASSERT(list[2] == NULL); for (i = 0; list[i] != NULL; ++i) free(list[i]); free(list); strcpy(input, "Steppenwolf"); list = string_split(input, ","); - if (!list) { Assert(0); return; } + if (!list) { ECCODES_ASSERT(0); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - Assert(i == 1); - if (!list[0] || !STR_EQUAL(list[0], "Steppenwolf")) Assert(0); - Assert(list[1] == NULL); + ECCODES_ASSERT(i == 1); + if (!list[0] || !STR_EQUAL(list[0], "Steppenwolf")) ECCODES_ASSERT(0); + ECCODES_ASSERT(list[1] == NULL); for (i = 0; list[i] != NULL; ++i) free(list[i]); free(list); @@ -241,14 +241,14 @@ static void test_assertion_catching() char empty[] = ""; char** list = NULL; - Assert(assertion_caught == 0); + ECCODES_ASSERT(assertion_caught == 0); codes_set_codes_assertion_failed_proc(&my_assertion_proc); /* Do something illegal */ list = string_split(empty, " "); - Assert(assertion_caught == 1); - Assert(list == NULL); + ECCODES_ASSERT(assertion_caught == 1); + ECCODES_ASSERT(list == NULL); /* Restore everything */ codes_set_codes_assertion_failed_proc(NULL); @@ -266,18 +266,18 @@ static void my_logging_proc(const grib_context* c, int level, const char* mesg) static void test_logging_proc() { grib_context* context = grib_context_get_default(); - Assert(logging_caught == 0); + ECCODES_ASSERT(logging_caught == 0); /* Override default behaviour */ grib_context_set_logging_proc(context, my_logging_proc); grib_context_log(context, GRIB_LOG_ERROR, "test_logging_proc: This error will be handled by me"); - Assert(logging_caught == 1); + ECCODES_ASSERT(logging_caught == 1); /* Restore the logging proc */ logging_caught = 0; grib_context_set_logging_proc(context, NULL); grib_context_log(context, GRIB_LOG_ERROR, "test_logging_proc: This error will come out as normal"); - Assert(logging_caught == 0); + ECCODES_ASSERT(logging_caught == 0); } static void my_print_proc(const grib_context* c, void* descriptor, const char* mesg) @@ -301,20 +301,20 @@ static void test_concept_condition_strings() if (!h) return; err = get_concept_condition_string(h, "typeOfLevel", NULL, result); - Assert(!err); - Assert(strcmp(result, "typeOfFirstFixedSurface=1,typeOfSecondFixedSurface=255") == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(strcmp(result, "typeOfFirstFixedSurface=1,typeOfSecondFixedSurface=255") == 0); err = get_concept_condition_string(h, "paramId", NULL, result); - Assert(!err); - Assert(strcmp(result, "discipline=0,parameterCategory=0,parameterNumber=0") == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(strcmp(result, "discipline=0,parameterCategory=0,parameterNumber=0") == 0); err = get_concept_condition_string(h, "gridType", NULL, result); - Assert(!err); - Assert(strcmp(result, "gridDefinitionTemplateNumber=0,PLPresent=0") == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(strcmp(result, "gridDefinitionTemplateNumber=0,PLPresent=0") == 0); err = get_concept_condition_string(h, "stepType", NULL, result); - Assert(!err); - Assert(strcmp(result, "selectStepTemplateInstant=1,stepTypeInternal=instant") == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(strcmp(result, "selectStepTemplateInstant=1,stepTypeInternal=instant") == 0); grib_handle_delete(h); } @@ -335,35 +335,35 @@ static void test_string_trimming() char* pE = e; string_lrtrim(&pA, 0, 1); /*right only*/ - Assert( strcmp(pA, " Standing")==0 ); + ECCODES_ASSERT( strcmp(pA, " Standing")==0 ); string_lrtrim(&pB, 1, 0); /*left only*/ - Assert( strcmp(pB, "Weeping ")==0 ); + ECCODES_ASSERT( strcmp(pB, "Weeping ")==0 ); string_lrtrim(&pC, 1, 1); /*both ends*/ - Assert( strcmp(pC, "Silhouette")==0 ); + ECCODES_ASSERT( strcmp(pC, "Silhouette")==0 ); string_lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/ - Assert( strcmp(pD, "The Forest Of October")==0 ); + ECCODES_ASSERT( strcmp(pD, "The Forest Of October")==0 ); string_lrtrim(&pE, 1, 1); /* Other chars */ - Assert( strcmp(pE, "Apostle In Triumph")==0 ); + ECCODES_ASSERT( strcmp(pE, "Apostle In Triumph")==0 ); } static void test_string_ends_with() { printf("Running %s ...\n", __func__); - Assert( string_ends_with("GRIB2.tmpl", "tmpl") == 1 ); - Assert( string_ends_with("GRIB2.tmpl", ".tmpl") == 1 ); - Assert( string_ends_with("", "") == 1 ); - Assert( string_ends_with(".", ".") == 1 ); - Assert( string_ends_with("Bam", "") == 1 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", "tmpl") == 1 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", ".tmpl") == 1 ); + ECCODES_ASSERT( string_ends_with("", "") == 1 ); + ECCODES_ASSERT( string_ends_with(".", ".") == 1 ); + ECCODES_ASSERT( string_ends_with("Bam", "") == 1 ); - Assert( string_ends_with("GRIB2.tmpl", "tmp") == 0 ); - Assert( string_ends_with("GRIB2.tmpl", "tmpl0") == 0 ); - Assert( string_ends_with("GRIB2.tmpl", "1.tmpl") == 0 ); - Assert( string_ends_with("GRIB2.tmpl", " ") == 0 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", "tmp") == 0 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", "tmpl0") == 0 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", "1.tmpl") == 0 ); + ECCODES_ASSERT( string_ends_with("GRIB2.tmpl", " ") == 0 ); } static void test_string_to_long() @@ -371,25 +371,25 @@ static void test_string_to_long() printf("Running %s ...\n", __func__); long lVal = 0; - Assert( string_to_long("0", &lVal, 1) == GRIB_SUCCESS); - Assert( lVal == 0 ); + ECCODES_ASSERT( string_to_long("0", &lVal, 1) == GRIB_SUCCESS); + ECCODES_ASSERT( lVal == 0 ); - Assert( string_to_long("42", &lVal, 1) == GRIB_SUCCESS); - Assert( lVal == 42 ); + ECCODES_ASSERT( string_to_long("42", &lVal, 1) == GRIB_SUCCESS); + ECCODES_ASSERT( lVal == 42 ); - Assert( string_to_long("-1", &lVal, 1) == GRIB_SUCCESS); - Assert( lVal == -1 ); - Assert( string_to_long("+999", &lVal, 1) == GRIB_SUCCESS); - Assert( lVal == 999 ); + ECCODES_ASSERT( string_to_long("-1", &lVal, 1) == GRIB_SUCCESS); + ECCODES_ASSERT( lVal == -1 ); + ECCODES_ASSERT( string_to_long("+999", &lVal, 1) == GRIB_SUCCESS); + ECCODES_ASSERT( lVal == 999 ); - Assert( string_to_long("15MB", &lVal, 0) == GRIB_SUCCESS); - Assert( lVal == 15 ); + ECCODES_ASSERT( string_to_long("15MB", &lVal, 0) == GRIB_SUCCESS); + ECCODES_ASSERT( lVal == 15 ); // illegal cases - Assert( string_to_long("4000000000000000000000", &lVal, 1) == GRIB_INVALID_ARGUMENT); - Assert( string_to_long("XY", &lVal, 1) == GRIB_INVALID_ARGUMENT); - Assert( string_to_long("A6", &lVal, 1) == GRIB_INVALID_ARGUMENT); - Assert( string_to_long("5K", &lVal, 1) == GRIB_INVALID_ARGUMENT); + ECCODES_ASSERT( string_to_long("4000000000000000000000", &lVal, 1) == GRIB_INVALID_ARGUMENT); + ECCODES_ASSERT( string_to_long("XY", &lVal, 1) == GRIB_INVALID_ARGUMENT); + ECCODES_ASSERT( string_to_long("A6", &lVal, 1) == GRIB_INVALID_ARGUMENT); + ECCODES_ASSERT( string_to_long("5K", &lVal, 1) == GRIB_INVALID_ARGUMENT); } static void test_string_replace_char() @@ -399,7 +399,7 @@ static void test_string_replace_char() char input[32] = {0,}; strncpy(input, "Mask Of Zoro", sizeof(input)); string_replace_char(input, ' ', '-'); - Assert(STR_EQUAL(input, "Mask-Of-Zoro")); + ECCODES_ASSERT(STR_EQUAL(input, "Mask-Of-Zoro")); } static void test_string_remove_char() @@ -407,7 +407,7 @@ static void test_string_remove_char() printf("Running %s ...\n", __func__); char input[64] = "a:b:c"; string_remove_char(input, ':'); - Assert(STR_EQUAL(input, "abc")); + ECCODES_ASSERT(STR_EQUAL(input, "abc")); } static void test_gribex_mode() @@ -415,14 +415,14 @@ static void test_gribex_mode() grib_context* c = grib_context_get_default(); printf("Running %s ...\n", __func__); - Assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */ + ECCODES_ASSERT( grib_get_gribex_mode(c) == 0 ); /* default is OFF */ grib_gribex_mode_on(c); codes_gribex_mode_on(c); - Assert( grib_get_gribex_mode(c) == 1 ); + ECCODES_ASSERT( grib_get_gribex_mode(c) == 1 ); grib_gribex_mode_off(c); codes_gribex_mode_off(c); - Assert( grib_get_gribex_mode(c) == 0 ); - Assert( codes_get_gribex_mode(c) == 0 ); + ECCODES_ASSERT( grib_get_gribex_mode(c) == 0 ); + ECCODES_ASSERT( codes_get_gribex_mode(c) == 0 ); } static void test_gts_header_mode() @@ -432,10 +432,10 @@ static void test_gts_header_mode() grib_gts_header_on(c); codes_gts_header_on(c); - Assert(c->gts_header_on == 1); + ECCODES_ASSERT(c->gts_header_on == 1); grib_gts_header_off(c); codes_gts_header_off(c); - Assert(c->gts_header_on == 0); + ECCODES_ASSERT(c->gts_header_on == 0); } static void test_data_quality_checks() @@ -468,18 +468,18 @@ static void test_grib_binary_search() size_t idx_upper=0, idx_lower = 0; grib_binary_search(array_asc, idx_asc_max, 56.0, &idx_upper, &idx_lower); - Assert(idx_lower == 1 && idx_upper == 2); + ECCODES_ASSERT(idx_lower == 1 && idx_upper == 2); grib_binary_search(array_asc, idx_asc_max, 56.1, &idx_upper, &idx_lower); - Assert(idx_lower == 2 && idx_upper == 3); + ECCODES_ASSERT(idx_lower == 2 && idx_upper == 3); grib_binary_search(array_asc, idx_asc_max, -0.1, &idx_upper, &idx_lower); - Assert(idx_lower == 0 && idx_upper == 1); + ECCODES_ASSERT(idx_lower == 0 && idx_upper == 1); grib_binary_search(array_desc, idx_desc_max, 88, &idx_upper, &idx_lower); - Assert(idx_lower == 0 && idx_upper == 1); + ECCODES_ASSERT(idx_lower == 0 && idx_upper == 1); grib_binary_search(array_desc, idx_desc_max, -88, &idx_upper, &idx_lower); - Assert(idx_lower == 2 && idx_upper == 3); + ECCODES_ASSERT(idx_lower == 2 && idx_upper == 3); grib_binary_search(array_desc, idx_desc_max, 1, &idx_upper, &idx_lower); - Assert(idx_lower == 1 && idx_upper == 2); + ECCODES_ASSERT(idx_lower == 1 && idx_upper == 2); } static void test_parse_keyval_string() @@ -500,18 +500,18 @@ static void test_parse_keyval_string() count = max_count; err = parse_keyval_string(NULL, input1, values_required, GRIB_TYPE_UNDEFINED, values1, &count); - Assert( !err ); - Assert( count == 2 ); + ECCODES_ASSERT( !err ); + ECCODES_ASSERT( count == 2 ); grib_print_values("print values test: values1", values1, stdout, count); - Assert( strcmp(values1[0].name, "key1")==0 ); - Assert( strcmp(values1[0].string_value, "value1")==0 ); - Assert( values1[0].equal == 1 ); - Assert( strcmp(values1[1].name, "key2")==0 ); - Assert( strcmp(values1[1].string_value, "value2")==0 ); - Assert( values1[1].equal == 0 ); + ECCODES_ASSERT( strcmp(values1[0].name, "key1")==0 ); + ECCODES_ASSERT( strcmp(values1[0].string_value, "value1")==0 ); + ECCODES_ASSERT( values1[0].equal == 1 ); + ECCODES_ASSERT( strcmp(values1[1].name, "key2")==0 ); + ECCODES_ASSERT( strcmp(values1[1].string_value, "value2")==0 ); + ECCODES_ASSERT( values1[1].equal == 0 ); /* Note how the input is modified by the tokenizer (thanks to strtok_r) */ - Assert( strcmp(input1, "key1=value1")==0 ); + ECCODES_ASSERT( strcmp(input1, "key1=value1")==0 ); free( (void*)values1[0].name ); free( (void*)values1[1].name ); free( (void*)values1[0].string_value ); @@ -520,21 +520,21 @@ static void test_parse_keyval_string() count = max_count; err = parse_keyval_string(NULL, input2, values_required, GRIB_TYPE_LONG, values2, &count); - Assert( !err ); - Assert( count == 1 ); + ECCODES_ASSERT( !err ); + ECCODES_ASSERT( count == 1 ); grib_print_values("print values test: values2", values2, stdout, count); - Assert( strcmp(values2[0].name, "x")==0 ); - Assert( values2[0].long_value == 14 ); - Assert( values2[0].equal == 1 ); + ECCODES_ASSERT( strcmp(values2[0].name, "x")==0 ); + ECCODES_ASSERT( values2[0].long_value == 14 ); + ECCODES_ASSERT( values2[0].equal == 1 ); free( (void*)values2[0].name ); count = max_count; err = parse_keyval_string(NULL, input3, values_required, GRIB_TYPE_DOUBLE, values3, &count); - Assert( !err ); - Assert( count == 1 ); + ECCODES_ASSERT( !err ); + ECCODES_ASSERT( count == 1 ); grib_print_values("print values test: values3", values3, stdout, count); - Assert( strcmp(values3[0].name, "mars.level")==0 ); + ECCODES_ASSERT( strcmp(values3[0].name, "mars.level")==0 ); free( (void*)values3[0].name ); } @@ -542,41 +542,41 @@ static void test_time_conversions() { printf("Running %s ...\n", __func__); long result = convert_to_minutes(120, 13); // 120s = 2mins - Assert(result == 2); + ECCODES_ASSERT(result == 2); } static void test_dates() { printf("Running %s ...\n", __func__); - Assert( is_date_valid(1979,12, 1, 0,0,0) ); - Assert( is_date_valid(1900, 1, 1, 0,0,0) ); - Assert( is_date_valid(1964, 4, 6, 0,0,0) ); - Assert( is_date_valid(2023, 3, 4, 0,0,0) ); - Assert( is_date_valid(2023, 3, 4, 12,0,0) ); - Assert( is_date_valid(2023, 3, 4, 0,10,0) ); - Assert( is_date_valid(2023, 3, 4, 0,0,59) ); - Assert( is_date_valid(0000, 3, 4, 0,0,0) ); - Assert( is_date_valid(2020, 2, 29, 0,0,0) );//leap year + ECCODES_ASSERT( is_date_valid(1979,12, 1, 0,0,0) ); + ECCODES_ASSERT( is_date_valid(1900, 1, 1, 0,0,0) ); + ECCODES_ASSERT( is_date_valid(1964, 4, 6, 0,0,0) ); + ECCODES_ASSERT( is_date_valid(2023, 3, 4, 0,0,0) ); + ECCODES_ASSERT( is_date_valid(2023, 3, 4, 12,0,0) ); + ECCODES_ASSERT( is_date_valid(2023, 3, 4, 0,10,0) ); + ECCODES_ASSERT( is_date_valid(2023, 3, 4, 0,0,59) ); + ECCODES_ASSERT( is_date_valid(0000, 3, 4, 0,0,0) ); + ECCODES_ASSERT( is_date_valid(2020, 2, 29, 0,0,0) );//leap year - Assert( !is_date_valid( 10, -1, 1, 0,0,0) );// bad months - Assert( !is_date_valid(1900, 0, 1, 0,0,0) ); - Assert( !is_date_valid(1900, 13, 1, 0,0,0) ); + ECCODES_ASSERT( !is_date_valid( 10, -1, 1, 0,0,0) );// bad months + ECCODES_ASSERT( !is_date_valid(1900, 0, 1, 0,0,0) ); + ECCODES_ASSERT( !is_date_valid(1900, 13, 1, 0,0,0) ); - Assert( !is_date_valid(1900, 5, 0, 0,0,0) ); // bad days - Assert( !is_date_valid(2000, 5, 32, 0,0,0) ); - Assert( !is_date_valid(2000, 5, -7, 0,0,0) ); + ECCODES_ASSERT( !is_date_valid(1900, 5, 0, 0,0,0) ); // bad days + ECCODES_ASSERT( !is_date_valid(2000, 5, 32, 0,0,0) ); + ECCODES_ASSERT( !is_date_valid(2000, 5, -7, 0,0,0) ); - Assert( !is_date_valid(2000, 5, 8, 99,0,0) );//bad hours - Assert( !is_date_valid(2000, 5, 9, -1,0,0) ); + ECCODES_ASSERT( !is_date_valid(2000, 5, 8, 99,0,0) );//bad hours + ECCODES_ASSERT( !is_date_valid(2000, 5, 9, -1,0,0) ); - Assert( !is_date_valid(2000, 5, 8, 0, 61,0) );//bad mins - Assert( !is_date_valid(2000, 5, 9, 0,-1, 0) ); + ECCODES_ASSERT( !is_date_valid(2000, 5, 8, 0, 61,0) );//bad mins + ECCODES_ASSERT( !is_date_valid(2000, 5, 9, 0,-1, 0) ); - Assert( !is_date_valid(2000, 5, 8, 0, 1, -1) );//bad secs - Assert( !is_date_valid(2000, 5, 9, 0, 1, 60) ); + ECCODES_ASSERT( !is_date_valid(2000, 5, 8, 0, 1, -1) );//bad secs + ECCODES_ASSERT( !is_date_valid(2000, 5, 9, 0, 1, 60) ); - Assert( !is_date_valid(2023, 2, 29, 0,0,0) );//Feb + ECCODES_ASSERT( !is_date_valid(2023, 2, 29, 0,0,0) );//Feb } void test_scale_factor_scaled_values() @@ -589,39 +589,39 @@ void test_scale_factor_scaled_values() const int64_t scale_factor_max = 255; // usually 1 octet err = compute_scaled_value_and_scale_factor(0, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 0); - Assert(factor == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 0); + ECCODES_ASSERT(factor == 0); err = compute_scaled_value_and_scale_factor(1, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 1); - Assert(factor == 0); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 1); + ECCODES_ASSERT(factor == 0); err = compute_scaled_value_and_scale_factor(1.5, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 15); - Assert(factor == 1); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 15); + ECCODES_ASSERT(factor == 1); err = compute_scaled_value_and_scale_factor(4.56, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 456); - Assert(factor == 2); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 456); + ECCODES_ASSERT(factor == 2); err = compute_scaled_value_and_scale_factor(-0.003, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == -3); - Assert(factor == 3); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == -3); + ECCODES_ASSERT(factor == 3); err = compute_scaled_value_and_scale_factor(145.889, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 145889); - Assert(factor == 3); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 145889); + ECCODES_ASSERT(factor == 3); err = compute_scaled_value_and_scale_factor(1111.00009, scaled_value_max, scale_factor_max, &value, &factor); - Assert(!err); - Assert(value == 111100009); - Assert(factor == 5); + ECCODES_ASSERT(!err); + ECCODES_ASSERT(value == 111100009); + ECCODES_ASSERT(factor == 5); } void test_iarray() @@ -695,23 +695,23 @@ void test_sarray() void test_codes_get_product_name() { printf("Running %s ...\n", __func__); - Assert( STR_EQUAL("ANY", codes_get_product_name(PRODUCT_ANY)) ); - Assert( STR_EQUAL("GRIB", codes_get_product_name(PRODUCT_GRIB)) ); - Assert( STR_EQUAL("BUFR", codes_get_product_name(PRODUCT_BUFR)) ); - Assert( STR_EQUAL("GTS", codes_get_product_name(PRODUCT_GTS)) ); - Assert( STR_EQUAL("METAR", codes_get_product_name(PRODUCT_METAR)) ); - Assert( STR_EQUAL("TAF", codes_get_product_name(PRODUCT_TAF)) ); + ECCODES_ASSERT( STR_EQUAL("ANY", codes_get_product_name(PRODUCT_ANY)) ); + ECCODES_ASSERT( STR_EQUAL("GRIB", codes_get_product_name(PRODUCT_GRIB)) ); + ECCODES_ASSERT( STR_EQUAL("BUFR", codes_get_product_name(PRODUCT_BUFR)) ); + ECCODES_ASSERT( STR_EQUAL("GTS", codes_get_product_name(PRODUCT_GTS)) ); + ECCODES_ASSERT( STR_EQUAL("METAR", codes_get_product_name(PRODUCT_METAR)) ); + ECCODES_ASSERT( STR_EQUAL("TAF", codes_get_product_name(PRODUCT_TAF)) ); } void test_codes_get_type_name() { printf("Running %s ...\n", __func__); - Assert( STR_EQUAL("long", codes_get_type_name(GRIB_TYPE_LONG)) ); - Assert( STR_EQUAL("string", grib_get_type_name(GRIB_TYPE_STRING)) ); - Assert( STR_EQUAL("double", grib_get_type_name(GRIB_TYPE_DOUBLE)) ); - Assert( STR_EQUAL("bytes", grib_get_type_name(GRIB_TYPE_BYTES)) ); - Assert( STR_EQUAL("label", grib_get_type_name(GRIB_TYPE_LABEL)) ); - Assert( STR_EQUAL("section", grib_get_type_name(GRIB_TYPE_SECTION)) ); + ECCODES_ASSERT( STR_EQUAL("long", codes_get_type_name(GRIB_TYPE_LONG)) ); + ECCODES_ASSERT( STR_EQUAL("string", grib_get_type_name(GRIB_TYPE_STRING)) ); + ECCODES_ASSERT( STR_EQUAL("double", grib_get_type_name(GRIB_TYPE_DOUBLE)) ); + ECCODES_ASSERT( STR_EQUAL("bytes", grib_get_type_name(GRIB_TYPE_BYTES)) ); + ECCODES_ASSERT( STR_EQUAL("label", grib_get_type_name(GRIB_TYPE_LABEL)) ); + ECCODES_ASSERT( STR_EQUAL("section", grib_get_type_name(GRIB_TYPE_SECTION)) ); } void test_grib2_choose_PDTN() @@ -720,10 +720,10 @@ void test_grib2_choose_PDTN() int det = true; int instant = true; - Assert( 0 == grib2_choose_PDTN(0, det, instant) ); - Assert( 8 == grib2_choose_PDTN(0, det, !instant) ); - Assert( 1 == grib2_choose_PDTN(0, !det, instant) ); - Assert( 11 == grib2_choose_PDTN(0, !det, !instant) ); + ECCODES_ASSERT( 0 == grib2_choose_PDTN(0, det, instant) ); + ECCODES_ASSERT( 8 == grib2_choose_PDTN(0, det, !instant) ); + ECCODES_ASSERT( 1 == grib2_choose_PDTN(0, !det, instant) ); + ECCODES_ASSERT( 11 == grib2_choose_PDTN(0, !det, !instant) ); } void test_grib2_select_PDTN() @@ -740,50 +740,50 @@ void test_grib2_select_PDTN() // arguments = eps instant chemical chemical_srcsink chemical_distfn aerosol aerosol_optical // Chemicals - Assert( 40 == grib2_select_PDTN(!eps, instant, chemical, 0, 0, 0, 0) ); - Assert( 41 == grib2_select_PDTN(eps, instant, chemical, 0, 0, 0, 0) ); - Assert( 42 == grib2_select_PDTN(!eps, !instant, chemical, 0, 0, 0, 0) ); - Assert( 43 == grib2_select_PDTN(eps, !instant, chemical, 0, 0, 0, 0) ); + ECCODES_ASSERT( 40 == grib2_select_PDTN(!eps, instant, chemical, 0, 0, 0, 0) ); + ECCODES_ASSERT( 41 == grib2_select_PDTN(eps, instant, chemical, 0, 0, 0, 0) ); + ECCODES_ASSERT( 42 == grib2_select_PDTN(!eps, !instant, chemical, 0, 0, 0, 0) ); + ECCODES_ASSERT( 43 == grib2_select_PDTN(eps, !instant, chemical, 0, 0, 0, 0) ); // Chemical source/sink - Assert( 76 == grib2_select_PDTN(!eps, instant, !chemical, chemical_srcsink, 0,0,0) ); - Assert( 77 == grib2_select_PDTN(eps, instant, !chemical, chemical_srcsink, 0,0,0) ); - Assert( 78 == grib2_select_PDTN(!eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); - Assert( 79 == grib2_select_PDTN(eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); + ECCODES_ASSERT( 76 == grib2_select_PDTN(!eps, instant, !chemical, chemical_srcsink, 0,0,0) ); + ECCODES_ASSERT( 77 == grib2_select_PDTN(eps, instant, !chemical, chemical_srcsink, 0,0,0) ); + ECCODES_ASSERT( 78 == grib2_select_PDTN(!eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); + ECCODES_ASSERT( 79 == grib2_select_PDTN(eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); // Chemical distrib. function - Assert( 58 == grib2_select_PDTN(eps, instant, 0, 0, chemical_distfn, 0, 0) ); - Assert( 68 == grib2_select_PDTN(eps, !instant, 0, 0, chemical_distfn, 0, 0) ); - Assert( 57 == grib2_select_PDTN(!eps, instant, 0, 0, chemical_distfn, 0, 0) ); - Assert( 67 == grib2_select_PDTN(!eps, !instant, 0, 0, chemical_distfn, 0, 0) ); + ECCODES_ASSERT( 58 == grib2_select_PDTN(eps, instant, 0, 0, chemical_distfn, 0, 0) ); + ECCODES_ASSERT( 68 == grib2_select_PDTN(eps, !instant, 0, 0, chemical_distfn, 0, 0) ); + ECCODES_ASSERT( 57 == grib2_select_PDTN(!eps, instant, 0, 0, chemical_distfn, 0, 0) ); + ECCODES_ASSERT( 67 == grib2_select_PDTN(!eps, !instant, 0, 0, chemical_distfn, 0, 0) ); // Aerosols - Assert( 50 == grib2_select_PDTN(!eps, instant, 0, 0, 0, aerosol, 0) ); - Assert( 46 == grib2_select_PDTN(!eps, !instant, 0, 0, 0, aerosol, 0) ); - Assert( 45 == grib2_select_PDTN(eps, instant, 0, 0, 0, aerosol, 0) ); - Assert( 85 == grib2_select_PDTN(eps, !instant, 0, 0, 0, aerosol, 0) ); + ECCODES_ASSERT( 50 == grib2_select_PDTN(!eps, instant, 0, 0, 0, aerosol, 0) ); + ECCODES_ASSERT( 46 == grib2_select_PDTN(!eps, !instant, 0, 0, 0, aerosol, 0) ); + ECCODES_ASSERT( 45 == grib2_select_PDTN(eps, instant, 0, 0, 0, aerosol, 0) ); + ECCODES_ASSERT( 85 == grib2_select_PDTN(eps, !instant, 0, 0, 0, aerosol, 0) ); // Aerosol optical - Assert( 49 == grib2_select_PDTN(eps, instant, 0, 0, 0, 0, aerosol_optical) ); - Assert( 48 == grib2_select_PDTN(!eps, instant, 0, 0, 0, 0, aerosol_optical) ); + ECCODES_ASSERT( 49 == grib2_select_PDTN(eps, instant, 0, 0, 0, 0, aerosol_optical) ); + ECCODES_ASSERT( 48 == grib2_select_PDTN(!eps, instant, 0, 0, 0, 0, aerosol_optical) ); // Plain vanilla - Assert( 0 == grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, !aerosol, 0) ); - Assert( 1 == grib2_select_PDTN(1,1,0,0,0, !aerosol,0) ); - Assert( 8 == grib2_select_PDTN(0,0,0,0,0, !aerosol,0) ); - Assert( 11 == grib2_select_PDTN(1,0,0,0,0, !aerosol,0) ); + ECCODES_ASSERT( 0 == grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, !aerosol, 0) ); + ECCODES_ASSERT( 1 == grib2_select_PDTN(1,1,0,0,0, !aerosol,0) ); + ECCODES_ASSERT( 8 == grib2_select_PDTN(0,0,0,0,0, !aerosol,0) ); + ECCODES_ASSERT( 11 == grib2_select_PDTN(1,0,0,0,0, !aerosol,0) ); //printf("%d\n", grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, aerosol, 0) ); - Assert( 1 == grib2_is_PDTN_EPS(1) ); - Assert( 1 == grib2_is_PDTN_EPS(11) ); - Assert( 0 == grib2_is_PDTN_EPS(0) ); + ECCODES_ASSERT( 1 == grib2_is_PDTN_EPS(1) ); + ECCODES_ASSERT( 1 == grib2_is_PDTN_EPS(11) ); + ECCODES_ASSERT( 0 == grib2_is_PDTN_EPS(0) ); } void test_codes_get_error_message() { printf("Running %s ...\n", __func__); const char* errmsg = grib_get_error_message(6666); - Assert( STR_EQUAL(errmsg, "Unknown error -6666")); + ECCODES_ASSERT( STR_EQUAL(errmsg, "Unknown error -6666")); } void test_codes_context_set_debug() @@ -798,13 +798,13 @@ void test_codes_context_set_debug() grib_handle* h = grib_handle_new_from_samples(context, "GRIB2"); if (!h) return; err = grib_set_long(h, "paramId", 167); - Assert(!err); + ECCODES_ASSERT(!err); printf("\tDisable debugging...\n"); grib_context_set_debug(context, 0); err = grib_set_long(h, "edition", 1); - Assert(!err); + ECCODES_ASSERT(!err); printf("\tEnable debugging again (verbose)...\n"); grib_context_set_debug(context, 1); grib_handle_delete(h); @@ -830,7 +830,7 @@ void test_codes_is_feature_enabled() const char* f = features[i]; printf("\tFeature %s enabled?\t%d\n", f, codes_is_feature_enabled(f)); } - Assert( 0 == codes_is_feature_enabled("total rubbish") ); + ECCODES_ASSERT( 0 == codes_is_feature_enabled("total rubbish") ); } void test_codes_get_features() @@ -840,7 +840,7 @@ void test_codes_get_features() size_t len = 512; char* features = (char*)calloc(len, sizeof(char)); int err = codes_get_features(features, &len, CODES_FEATURES_ALL); - Assert(!err); + ECCODES_ASSERT(!err); printf("\tFeatures are: '%s'\n", features); len = 512; @@ -859,16 +859,16 @@ static void test_grib_get_binary_scale_fact() printf("Running %s ...\n", __func__); int err = 0; long result = grib_get_binary_scale_fact(INFINITY, 0, 0, &err); - Assert(err == GRIB_OUT_OF_RANGE); - Assert(result == 0); + ECCODES_ASSERT(err == GRIB_OUT_OF_RANGE); + ECCODES_ASSERT(result == 0); result = grib_get_binary_scale_fact(100, 0, 65, &err); // bpv too big - Assert(err == GRIB_OUT_OF_RANGE); - Assert(result == 0); + ECCODES_ASSERT(err == GRIB_OUT_OF_RANGE); + ECCODES_ASSERT(result == 0); result = grib_get_binary_scale_fact(100, 0, 0, &err); // bpv 0 - Assert(err == GRIB_ENCODING_ERROR); - Assert(result == 0); + ECCODES_ASSERT(err == GRIB_ENCODING_ERROR); + ECCODES_ASSERT(result == 0); } static void test_filepool() diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 26ebad36a..c04c2cd7a 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -190,7 +190,7 @@ static int blocklisted(const char* name) grib_string_list* b = blocklist; if (!name) return 0; while (b) { - Assert(b->value); + ECCODES_ASSERT(b->value); if (!strcmp(name, b->value)) return 1; b = b->next; @@ -748,7 +748,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g return GRIB_COUNT_MISMATCH; } */ - Assert(options->mode == MODE_BUFR); + ECCODES_ASSERT(options->mode == MODE_BUFR); /* TODO: Ignore missing values for keys in BUFR. Not yet implemented */ //isMissing1 = ((grib_is_missing(handle1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; //isMissing2 = ((grib_is_missing(handle2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index bc250eb37..bd2fa6c2b 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -179,7 +179,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi if (!options->current_infile->name) return 0; - Assert(file); + ECCODES_ASSERT(file); exit_if_input_is_directory(tool_name, file->name); /* @@ -325,7 +325,7 @@ static void bufr_dump_descriptors(grib_handle* h) exit(GRIB_OUT_OF_MEMORY); } GRIB_CHECK_NOLINE(grib_get_string_array(h, the_key, array_abbrevs, &size_abbrevs), 0); - Assert(size_proper == size_abbrevs); + ECCODES_ASSERT(size_proper == size_abbrevs); the_key = "expandedNames"; GRIB_CHECK_NOLINE(grib_get_size(h, the_key, &size_names), 0); @@ -335,7 +335,7 @@ static void bufr_dump_descriptors(grib_handle* h) exit(GRIB_OUT_OF_MEMORY); } GRIB_CHECK_NOLINE(grib_get_string_array(h, the_key, array_names, &size_names), 0); - Assert(size_proper == size_names); + ECCODES_ASSERT(size_proper == size_names); the_key = "expandedUnits"; GRIB_CHECK_NOLINE(grib_get_size(h, the_key, &size_units), 0); @@ -345,7 +345,7 @@ static void bufr_dump_descriptors(grib_handle* h) exit(GRIB_OUT_OF_MEMORY); } GRIB_CHECK_NOLINE(grib_get_string_array(h, the_key, array_units, &size_units), 0); - Assert(size_proper == size_units); + ECCODES_ASSERT(size_proper == size_units); i = 0; j = 0; @@ -432,7 +432,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) /* Clone, unpack and extract that particular subset */ h2 = grib_handle_clone(h); - Assert(h2); + ECCODES_ASSERT(h2); GRIB_CHECK_NOLINE(grib_set_long(h2, "unpack", 1), 0); GRIB_CHECK_NOLINE(grib_set_long(h2, "extractSubset", subsetNumber), 0); GRIB_CHECK_NOLINE(grib_set_long(h2, "doExtractSubsets", 1), 0); @@ -440,7 +440,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) /* Put result into buffer then form new handle from it */ GRIB_CHECK_NOLINE(grib_get_message(h2, &buffer, &size), 0); new_handle = grib_handle_new_from_message(0, buffer, size); - Assert(new_handle); + ECCODES_ASSERT(new_handle); /* Replace handle with the new one which has only one subset */ h = new_handle; hclone = h2; /* to be deleted later */ diff --git a/tools/bufr_split_by_rdbSubtype.cc b/tools/bufr_split_by_rdbSubtype.cc index 2db7d7bbf..857ab94fa 100644 --- a/tools/bufr_split_by_rdbSubtype.cc +++ b/tools/bufr_split_by_rdbSubtype.cc @@ -52,7 +52,7 @@ static int decode_rdbSubtype(const void* msg, long* rdbSubtype) int ecmwfLocalSectionPresent = 0; const unsigned char* message = (const unsigned char*)msg; - Assert(message); + ECCODES_ASSERT(message); *rdbSubtype = -1; /* default */ edition = (long)grib_decode_unsigned_long(message, &pos_edition, nbits_edition); diff --git a/tools/grib2ppm.cc b/tools/grib2ppm.cc index 820178789..5a2b1d623 100644 --- a/tools/grib2ppm.cc +++ b/tools/grib2ppm.cc @@ -185,7 +185,7 @@ int main(int argc, char* argv[]) for (jj = 0; jj < height; jj++) { for (i = 0; i < width; i++) { int m = (i + width / 2) % width + jj * width; - Assert(k < count); + ECCODES_ASSERT(k < count); indices[k++] = m; } } diff --git a/tools/grib_check_gaussian_grid.cc b/tools/grib_check_gaussian_grid.cc index 666658490..911154f1c 100644 --- a/tools/grib_check_gaussian_grid.cc +++ b/tools/grib_check_gaussian_grid.cc @@ -125,7 +125,7 @@ static int process_file(const char* filename) GRIB_CHECK(grib_get_double(h, "longitudeOfLastGridPointInDegrees", &lon2), 0); GRIB_CHECK(grib_get_long(h, "angleSubdivisions", &angleSubdivisions), 0); - Assert(angleSubdivisions > 0); + ECCODES_ASSERT(angleSubdivisions > 0); angular_tolerance = 1.0/angleSubdivisions; if (N <= 0) { @@ -166,9 +166,9 @@ static int process_file(const char* filename) long iDirectionIncrementGiven = 0; is_missing_Ni = grib_is_missing(h, "Ni", &err); - Assert(err == GRIB_SUCCESS); + ECCODES_ASSERT(err == GRIB_SUCCESS); is_missing_Di = grib_is_missing(h, "iDirectionIncrement", &err); - Assert(err == GRIB_SUCCESS); + ECCODES_ASSERT(err == GRIB_SUCCESS); GRIB_CHECK(grib_get_long(h, "iDirectionIncrementGiven", &iDirectionIncrementGiven), 0); if (iDirectionIncrementGiven) { error(filename, msg_num, "For a reduced grid, iDirectionIncrementGiven should be 0\n"); @@ -181,12 +181,12 @@ static int process_file(const char* filename) } GRIB_CHECK(grib_get_size(h, "pl", &pl_len), 0); - Assert(pl_len > 0); + ECCODES_ASSERT(pl_len > 0); if (pl_len != (size_t)(2 * N)) { error(filename, msg_num, "Length of pl array is %ld but should be 2*N (%ld)\n", pl_len, 2 * N); } pl = (long*)malloc(pl_len * sizeof(long)); - Assert(pl); + ECCODES_ASSERT(pl); GRIB_CHECK(grib_get_long_array(h, "pl", pl, &pl_len), 0); max_pl = pl[0]; diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index 903534d8e..0a0058aa4 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -195,7 +195,7 @@ static int blocklisted(const char* name) { grib_string_list* b = blocklist; while (b) { - Assert(b->value); + ECCODES_ASSERT(b->value); if (!strcmp(name, b->value)) return 1; b = b->next; diff --git a/tools/grib_dump.cc b/tools/grib_dump.cc index 7227ca8fa..b462f1de7 100644 --- a/tools/grib_dump.cc +++ b/tools/grib_dump.cc @@ -127,7 +127,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi if (json) return 0; - Assert(file); + ECCODES_ASSERT(file); exit_if_input_is_directory(tool_name, file->name); snprintf(tmp, sizeof(tmp), "FILE: %s ", options->current_infile->name); diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index 14c07790f..e9bd8fc71 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -145,7 +145,7 @@ static bool eq_time(const char* l, const char* r) static value* new_value(const char* name) { value* v = (value*)calloc(1, sizeof(value)); - Assert(v); + ECCODES_ASSERT(v); v->name = grib_context_strdup(ctx, name); return v; } @@ -287,7 +287,7 @@ static bool is_number(const char* name) static parameter* new_parameter(char* name, value* v) { parameter* p = (parameter*)calloc(1, sizeof(parameter)); - Assert(p); + ECCODES_ASSERT(p); p->name = grib_context_strdup(ctx, name); p->values = v; return p; @@ -577,10 +577,10 @@ static err handle_to_request(request* r, grib_handle* g) } /* - Assert(grib_get_long(g, "validityDate", &l ) == 0); + ECCODES_ASSERT(grib_get_long(g, "validityDate", &l ) == 0); set_value(r, "validityDate", "%ld", l); - Assert(grib_get_long(g, "validityTime", &l ) == 0); + ECCODES_ASSERT(grib_get_long(g, "validityTime", &l ) == 0); set_value(r, "validityTime", "%ld", l); */ @@ -725,7 +725,7 @@ static int ecc_cube_position(const hypercube* h, const request* r, bool remove_h static value* clone_one_value(const value* p) { value* q = (value*)calloc(1, sizeof(value)); - Assert(q); + ECCODES_ASSERT(q); q->next = NULL; q->name = grib_context_strdup(ctx, p->name); return q; @@ -745,7 +745,7 @@ static value* clone_all_values(const value* p) static parameter* clone_one_parameter(const parameter* p) { parameter* q = (parameter*)calloc(1, sizeof(parameter)); - Assert(q); + ECCODES_ASSERT(q); q->next = NULL; q->name = grib_context_strdup(ctx, p->name); q->values = clone_all_values(p->values); @@ -766,7 +766,7 @@ static request* clone_one_request(const request* r) { if (r) { request* p = (request*)calloc(1, sizeof(request)); - Assert(p); + ECCODES_ASSERT(p); p->name = grib_context_strdup(ctx, r->name); p->params = clone_all_parameters(r->params); @@ -779,7 +779,7 @@ static request* clone_one_request(const request* r) static request* new_request(const char* name, parameter* p) { request* r = (request*)calloc(1, sizeof(request)); - Assert(r); + ECCODES_ASSERT(r); r->name = grib_context_strdup(ctx, name); r->params = p; return r; @@ -866,11 +866,11 @@ static void grow_fieldset(fieldset* v, int n) int i; if (v->fields == NULL) { v->fields = (field**)grib_context_malloc(ctx, sizeof(field*) * v->max); - Assert(v->fields); + ECCODES_ASSERT(v->fields); } else { field** f = (field**)grib_context_malloc(ctx, sizeof(field*) * v->max); - Assert(f); + ECCODES_ASSERT(f); for (i = 0; i < m; i++) f[i] = v->fields[i]; grib_context_free(ctx, v->fields); @@ -885,7 +885,7 @@ static void grow_fieldset(fieldset* v, int n) static fieldset* new_fieldset(int n) { fieldset* f = (fieldset*)calloc(1, sizeof(fieldset)); - Assert(f); + ECCODES_ASSERT(f); grow_fieldset(f, n); return f; } @@ -989,7 +989,7 @@ static err to_expand_mem(field* g) { err e = 0; - Assert(g); + ECCODES_ASSERT(g); if (g->shape == expand_mem) return 0; @@ -1005,7 +1005,7 @@ static err to_expand_mem(field* g) fseeko(file->handle, g->offset, SEEK_SET); g->handle = grib_handle_new_from_file(ctx, file->handle, &e); - Assert(g->handle); + ECCODES_ASSERT(g->handle); if (g->handle) grib_get_message(g->handle, &dummy, &g->length); @@ -1392,7 +1392,7 @@ static void set_index(hypercube* h, int index, int value) h->max += 4096; h->set = h->set ? (char*)grib_context_realloc(ctx, h->set, h->max) : (char*)grib_context_malloc(ctx, h->max); - Assert(h->set); + ECCODES_ASSERT(h->set); memset(h->set + old, 0, h->max - old); } @@ -1552,7 +1552,7 @@ static void reserve_index_cache(hypercube* h, int size) grib_context_free(ctx, h->index_cache); grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: Allocating hypercube index_cache: %d entries", size); h->index_cache = (int*)calloc(size, sizeof(int)); - Assert(h->index_cache); + ECCODES_ASSERT(h->index_cache); h->index_cache_size = size; } @@ -1631,18 +1631,18 @@ static void cube_indexes( int last = h->index_cache[i]; const bool is_time_axis = (STR_EQUAL(axis, "time")); if (is_time_axis) { - Assert(times_array); - Assert(times_array_size == count); + ECCODES_ASSERT(times_array); + ECCODES_ASSERT(times_array_size == count); } for (k = 0; k < count; k++) { j = (k + last) % count; if (is_time_axis) { /* GRIB-792: use fast lookup */ - Assert(j >= 0 && j < times_array_size); + ECCODES_ASSERT(j >= 0 && j < times_array_size); w = times_array[j]; /* For testing: - * Assert( strcmp(w, get_value(cube, axis, j))==0 ); + * ECCODES_ASSERT( strcmp(w, get_value(cube, axis, j))==0 ); * */ } else { @@ -1672,7 +1672,7 @@ static hypercube* new_hypercube(const request* r) int total = 0, count = 0; size_t n = 0; const char* val = 0; - Assert(h); + ECCODES_ASSERT(h); h->r = clone_one_request(r); h->cube = empty_request("CUBE"); @@ -1701,7 +1701,7 @@ static hypercube* new_hypercube(const request* r) static void print_hypercube(const hypercube* h) { - Assert(h); + ECCODES_ASSERT(h); if (!h) return; print_all_requests(h->r); print_all_requests(h->cube); @@ -1776,7 +1776,7 @@ static hypercube* new_hypercube_from_mars_request(const request* r) n = count_values(s.c->cube, "axis"); if (n) { s.c->compare = (namecmp*)calloc(n, sizeof(namecmp)); - Assert(s.c->compare); + ECCODES_ASSERT(s.c->compare); } for (i = 0; i < n; i++) @@ -1803,7 +1803,7 @@ static hypercube* new_simple_hypercube_from_mars_request(const request* r) n = count_values(s.c->cube, "axis"); if (n) { s.c->compare = (namecmp*)calloc(n, sizeof(namecmp)); - Assert(s.c->compare); + ECCODES_ASSERT(s.c->compare); } for (i = 0; i < n; i++) @@ -2219,7 +2219,7 @@ static int get_num_latitudes_longitudes(grib_handle* h, size_t* nlats, size_t* n strcmp(grid_type, "regular_ll") == 0) { /* Special shortcut for regular lat/on grids */ long n; - Assert(!grib_is_missing(h, "Ni", &e)); + ECCODES_ASSERT(!grib_is_missing(h, "Ni", &e)); if ((e = grib_get_long(h, "Ni", &n)) != GRIB_SUCCESS) { grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get Ni: %s", grib_get_error_message(e)); return e; @@ -2567,7 +2567,7 @@ static void scale_bitmap(double* vals, long n, void* data, dataset_t* subset) return; } */ if (n > 0 && !vals) { - Assert(!"scale_bitmap: n > 0 but vals == NULL"); + ECCODES_ASSERT(!"scale_bitmap: n > 0 but vals == NULL"); return; } @@ -2667,7 +2667,7 @@ static void scale(double* vals, long n, void* data, dataset_t* g) for (i = 0; i < n; ++i) { if (!g->bitmap || (vals[i] != global_missing_value)) { double d = 0; - Assert(scale_factor > 0); + ECCODES_ASSERT(scale_factor > 0); d = rint((vals[i] - add_offset) / scale_factor); if (!(d >= nc_type_values[nctype].nc_type_min && d <= nc_type_values[nctype].nc_type_max)) { grib_context_log(ctx, GRIB_LOG_ERROR, "Scaling for type NC_SHORT failed"); @@ -2905,7 +2905,7 @@ static void set_always_a_time(hypercube* h, request* data_r) int n = count_values(h->cube, "axis"); if (n) { h->compare = (namecmp*)calloc(n, sizeof(namecmp)); - Assert(h->compare); + ECCODES_ASSERT(h->compare); } for (i = 0; i < n; i++) @@ -3629,11 +3629,11 @@ static int split_fieldset(fieldset* fs, request* data_r, dataset_t** subsets, co free_all_requests(s); filters = (dataset_t*)calloc(count, sizeof(dataset_t)); - Assert(filters); + ECCODES_ASSERT(filters); s = u; for (i = 0; i < count; ++i) { - Assert(s); + ECCODES_ASSERT(s); filters[i].filter = new_hypercube_from_mars_request(s); filters[i].fset = new_fieldset(1); filters[i].count = 0; @@ -4168,12 +4168,12 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil /* process only GRIB for the moment*/ size_t size = sizeof(buf); - Assert(grib_get_string(h, "identifier", buf, &size) == 0); + ECCODES_ASSERT(grib_get_string(h, "identifier", buf, &size) == 0); if (strcmp(buf, "GRIB")) { grib_handle_delete(h); continue; } - Assert(grib_get_long(h, "totalLength", &length) == 0); + ECCODES_ASSERT(grib_get_long(h, "totalLength", &length) == 0); g = read_field(file, h->offset, length); diff --git a/tools/grib_tools.cc b/tools/grib_tools.cc index 8c05058b2..bdecd5e3f 100644 --- a/tools/grib_tools.cc +++ b/tools/grib_tools.cc @@ -140,7 +140,7 @@ static grib_handle* grib_handle_new_from_file_x(grib_context* c, FILE* f, int mo if (mode == MODE_TAF) return taf_new_from_file(c, f, err); - Assert(!"grib_handle_new_from_file_x: unknown mode"); + ECCODES_ASSERT(!"grib_handle_new_from_file_x: unknown mode"); return NULL; } @@ -178,7 +178,7 @@ int grib_tool(int argc, char** argv) grib_tool_init(&global_options); - Assert(global_options.dump_filename == NULL); + ECCODES_ASSERT(global_options.dump_filename == NULL); dump_file = stdout; // if (global_options.dump_filename) { // dump_file = fopen(global_options.dump_filename, "w"); @@ -842,7 +842,7 @@ static int to_skip(grib_runtime_options* options, grib_handle* h, grib_values* v size_t len = MAX_STRING_LEN; *err = 0; - Assert(options->constraints_count > 0); + ECCODES_ASSERT(options->constraints_count > 0); if (strcmp(v->name, "count")==0 && v->long_value < 1) { fprintf(dump_file, "ERROR: Invalid value for key '%s' (must be an integer greater than 0)\n", v->name); @@ -979,7 +979,7 @@ static int get_initial_element_of_array(grib_handle* h, const char* keyName, siz double* dval = NULL; grib_context* c = h->context; - Assert(num_vals > 1); /* This is for array keys */ + ECCODES_ASSERT(num_vals > 1); /* This is for array keys */ if ((err = grib_get_native_type(h, keyName, &type)) != GRIB_SUCCESS) return err; switch (type) { @@ -1337,7 +1337,7 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) void grib_print_file_statistics(grib_runtime_options* options, grib_tools_file* file) { grib_failed* failed = NULL; - Assert(file); + ECCODES_ASSERT(file); if (options->json_output && !options->latlon) return; @@ -1391,7 +1391,7 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h) grib_file* of = NULL; int err = 0; char filename[1024] = {0,}; - Assert(options->outfile != NULL && options->outfile->name != NULL); + ECCODES_ASSERT(options->outfile != NULL && options->outfile->name != NULL); /* See ECC-1086 * if (options->error == GRIB_WRONG_LENGTH) diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index 4ceab0f9f..35d1f916d 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -127,7 +127,7 @@ static int blocklisted(const char* name) grib_string_list* b = blocklist; if (!name) return 0; while (b) { - Assert(b->value); + ECCODES_ASSERT(b->value); if (!strcmp(name, b->value)) return 1; b = b->next; @@ -424,7 +424,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, save_error(c, name); return err; } - Assert(options->mode == MODE_GTS); + ECCODES_ASSERT(options->mode == MODE_GTS); /* TODO: Ignore missing values for keys in GTS. Not yet implemented */ //isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; //isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index 127ed56c5..db9759761 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -150,7 +150,7 @@ static int blocklisted(const char* name) grib_string_list* b = blocklist; if (!name) return 0; while (b) { - Assert(b->value); + ECCODES_ASSERT(b->value); if (!strcmp(name, b->value)) return 1; b = b->next; @@ -491,7 +491,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, return err; } - Assert(options->mode == MODE_METAR); + ECCODES_ASSERT(options->mode == MODE_METAR); // // TODO: Ignore missing values for keys in METAR. Not yet implemented // isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; // isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; diff --git a/tools/metar_copy.cc b/tools/metar_copy.cc index 2e9fbb38b..41644ad92 100644 --- a/tools/metar_copy.cc +++ b/tools/metar_copy.cc @@ -72,7 +72,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) { - Assert(options->set_values_count==0); // Cannot set keys in this tool + ECCODES_ASSERT(options->set_values_count==0); // Cannot set keys in this tool // int err = 0; // if (!options->skip) {