Skip to content

Commit

Permalink
Rename macro: Assert -> ECCODES_ASSERT
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Dec 20, 2024
1 parent 57ccd4b commit 9a621fc
Show file tree
Hide file tree
Showing 197 changed files with 916 additions and 916 deletions.
34 changes: 17 additions & 17 deletions fortran/grib_fortran.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_ascii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/accessor/grib_accessor_class_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_bits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_budgdate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/accessor/grib_accessor_class_bufr_data_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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! "
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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_) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bufr_data_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down Expand Up @@ -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])) {
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bufr_elements_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_cf_var_name.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/accessor/grib_accessor_class_change_scanning_direction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/accessor/grib_accessor_class_check_internal_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 9a621fc

Please sign in to comment.