Rename assertion macros

This commit is contained in:
Shahram Najm 2023-06-26 21:21:07 +01:00
parent 7dc8a1a4a6
commit aecac9dd98
50 changed files with 151 additions and 161 deletions

View File

@ -95,7 +95,7 @@ void grib_dump(grib_action* a, FILE* f, int l)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
}
void grib_xref(grib_action* a, FILE* f, const char* path)
@ -111,7 +111,7 @@ void grib_xref(grib_action* a, FILE* f, const char* path)
c = c->super ? *(c->super) : NULL;
}
printf("xref not implemented for %s\n", a->cclass->name);
DebugAssert(0);
DEBUG_ASSERT(0);
}
@ -144,7 +144,7 @@ int grib_create_accessor(grib_section* p, grib_action* a, grib_loader* h)
c = c->super ? *(c->super) : NULL;
}
fprintf(stderr, "Cannot create accessor %s %s\n", a->name, a->cclass->name);
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -167,7 +167,7 @@ int grib_action_notify_change(grib_action* a, grib_accessor* observer, grib_acce
c = c->super ? *(c->super) : NULL;
}
/*GRIB_MUTEX_UNLOCK(&mutex1);*/
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -180,7 +180,7 @@ grib_action* grib_action_reparse(grib_action* a, grib_accessor* acc, int* doit)
return c->reparse(a, acc, doit);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -193,7 +193,7 @@ int grib_action_execute(grib_action* a, grib_handle* h)
return c->execute(a, h);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}

View File

@ -29,7 +29,7 @@ bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h, unsigned long f
ki->filter_flags = filter_flags;
ki->handle = h;
DebugAssert(h->product_kind == PRODUCT_BUFR);
DEBUG_ASSERT(h->product_kind == PRODUCT_BUFR);
ki->key_name = NULL;
ki->i_curr_attribute = 0;
ki->accessor_flags_only = GRIB_ACCESSOR_FLAG_DUMP;
@ -56,7 +56,7 @@ bufr_keys_iterator* codes_bufr_data_section_keys_iterator_new(grib_handle* h)
return NULL;
ki->handle = h;
DebugAssert(h->product_kind == PRODUCT_BUFR);
DEBUG_ASSERT(h->product_kind == PRODUCT_BUFR);
ki->i_curr_attribute = 0;
ki->accessor_flags_only = GRIB_ACCESSOR_FLAG_BUFR_DATA | GRIB_ACCESSOR_FLAG_DUMP;
ki->accessor_flags_skip = GRIB_ACCESSOR_FLAG_HIDDEN | GRIB_ACCESSOR_FLAG_READ_ONLY;
@ -200,7 +200,7 @@ char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter)
int* r = 0;
char* ret = 0;
grib_context* c = kiter->handle->context;
DebugAssert(kiter->current);
DEBUG_ASSERT(kiter->current);
if (kiter->prefix) {
int iattribute = kiter->i_curr_attribute - 1;

View File

@ -19,20 +19,20 @@ int compute_bufr_key_rank(grib_handle* h, grib_string_list* keys, const char* ke
int theRank = 0;
size_t size = 0;
grib_context* c = h->context;
DebugAssert(h->product_kind == PRODUCT_BUFR);
DEBUG_ASSERT(h->product_kind == PRODUCT_BUFR);
while (next && next->value && strcmp(next->value, key)) {
prev = next;
next = next->next;
}
if (!next) {
DebugAssert(prev);
DEBUG_ASSERT(prev);
if (prev) {
prev->next = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list));
next = prev->next;
}
}
DebugAssert(next);
DEBUG_ASSERT(next);
if (!next) return 0;
if (!next->value) {
@ -166,7 +166,7 @@ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes
unsigned char* p = (unsigned char*)message + offset_keyData;
DebugAssert(hdr->ecmwfLocalSectionPresent);
DEBUG_ASSERT(hdr->ecmwfLocalSectionPresent);
hdr->rdbType = (long)grib_decode_unsigned_long(pMessage, &pos_rdbType, nbits_rdbType);
hdr->oldSubtype = (long)grib_decode_unsigned_long(pMessage, &pos_oldSubtype, nbits_oldSubtype);
@ -218,7 +218,7 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
unsigned char* pKeyData = (unsigned char*)message + offset_keyData;
char* pKeyMore = (char*)message + offset_keyMore;
DebugAssert(hdr->ecmwfLocalSectionPresent);
DEBUG_ASSERT(hdr->ecmwfLocalSectionPresent);
if (hdr->rdbType == 2 || hdr->rdbType == 3 || hdr->rdbType == 8 || hdr->rdbType == 12) {
isSatelliteType = true;

View File

@ -38,7 +38,7 @@ void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
}
int grib_pack_missing(grib_accessor* a)
@ -51,7 +51,7 @@ int grib_pack_missing(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -65,7 +65,7 @@ int grib_pack_zero(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -79,7 +79,7 @@ int grib_is_missing_internal(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -93,7 +93,7 @@ int grib_pack_double(grib_accessor* a, const double* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -106,7 +106,7 @@ int grib_pack_float(grib_accessor* a, const float* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -120,7 +120,7 @@ int grib_pack_expression(grib_accessor* a, grib_expression* e)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -134,7 +134,7 @@ int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -148,7 +148,7 @@ int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -162,7 +162,7 @@ int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -176,7 +176,7 @@ int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -190,7 +190,7 @@ int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -203,7 +203,7 @@ int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -217,7 +217,7 @@ int grib_unpack_double(grib_accessor* a, double* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -231,7 +231,7 @@ int grib_unpack_float(grib_accessor* a, float* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -277,7 +277,7 @@ int grib_unpack_float_element(grib_accessor* a, size_t i, float* v)
int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
{
grib_accessor_class* c = a->cclass;
DebugAssert(len > 0);
DEBUG_ASSERT(len > 0);
while (c) {
if (c->unpack_double_element_set) {
return c->unpack_double_element_set(a, index_array, len, val_array);
@ -290,7 +290,7 @@ int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, s
{
/*
*grib_accessor_class* c = a->cclass;
*DebugAssert(len > 0);
*DEBUG_ASSERT(len > 0);
*while (c) {
* if (c->unpack_float_element_set) {
* return c->unpack_float_element_set(a, index_array, len, val_array);
@ -311,7 +311,7 @@ int grib_unpack_string(grib_accessor* a, char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -324,7 +324,7 @@ int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -406,7 +406,7 @@ int grib_unpack_long(grib_accessor* a, long* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -421,7 +421,7 @@ long grib_accessor_get_native_type(grib_accessor* a)
return c->get_native_type(a);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -437,7 +437,7 @@ long grib_get_next_position_offset(grib_accessor* a)
return c->next_offset(a);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -452,7 +452,7 @@ long grib_string_length(grib_accessor* a)
return c->string_length(a);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -467,7 +467,7 @@ long grib_byte_offset(grib_accessor* a)
return c->byte_offset(a);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -482,7 +482,7 @@ long grib_byte_count(grib_accessor* a)
return c->byte_count(a);
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -500,7 +500,7 @@ int grib_value_count(grib_accessor* a, long* count)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -529,7 +529,7 @@ int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed)
}
if (a && a->cclass)
printf("notify_change not implemented for %s %s\n", a->cclass->name, a->name);
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -593,7 +593,7 @@ void grib_update_size(grib_accessor* a, size_t len)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
}
int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
@ -605,7 +605,7 @@ int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -620,7 +620,7 @@ size_t grib_preferred_size(grib_accessor* a, int from_handle)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -633,7 +633,7 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return 0;
}
@ -648,7 +648,7 @@ void grib_resize(grib_accessor* a, size_t new_size)
}
c = c->super ? *(c->super) : NULL;
}
DebugAssert(0);
DEBUG_ASSERT(0);
return;
}

View File

@ -248,11 +248,11 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l)
l->last = a;
if (hand->use_trie) {
DebugAssert( a->all_names[0] );
DEBUG_ASSERT( a->all_names[0] );
if (*(a->all_names[0]) != '_') {
id = grib_hash_keys_get_id(a->context->keys, a->all_names[0]);
DebugAssert(id >= 0 && id < ACCESSORS_ARRAY_SIZE);
DEBUG_ASSERT(id >= 0 && id < ACCESSORS_ARRAY_SIZE);
a->same = hand->accessors[id];
link_same_attributes(a, a->same);

View File

@ -770,7 +770,7 @@ static int descriptor_get_min_max(bufr_descriptor* bd, long width, long referenc
if (width <= 0)
return GRIB_MISSING_BUFR_ENTRY; /* ECC-1395 */
DebugAssert(width > 0 && width < 64);
DEBUG_ASSERT(width > 0 && width < 64);
*maxAllowed = (max1 + reference) * factor;
*minAllowed = reference * factor;
@ -1387,7 +1387,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array
int err = 0;
unsigned long repetitions = 1;
bufr_descriptor** descriptors = self->expanded->v;
DebugAssert( buff->data == data );
DEBUG_ASSERT( buff->data == data );
switch (descriptors[i]->code) {
case 31000:
@ -1521,7 +1521,7 @@ static int encode_replication(grib_context* c, grib_accessor_bufr_data_array* se
{
/* Assert( buff->data == data); */
if (self->compressedData) {
DebugAssert(grib_darray_used_size(self->numericValues->v[elementIndex]) == 1);
DEBUG_ASSERT(grib_darray_used_size(self->numericValues->v[elementIndex]) == 1);
*numberOfRepetitions = self->numericValues->v[elementIndex]->v[0];
}
else {
@ -1757,7 +1757,7 @@ static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_a
i = self->bitmapCurrent;
if (self->compressedData) {
DebugAssert(i < self->nInputBitmap);
DEBUG_ASSERT(i < self->nInputBitmap);
if (i >= self->nInputBitmap)
return GRIB_WRONG_BITMAP_SIZE;
while (self->inputBitmap[i] == 1) {
@ -1797,7 +1797,7 @@ static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self,
self->bitmapCurrent++;
self->bitmapCurrentElementsDescriptorsIndex++;
i = self->bitmapCurrent + self->bitmapStart;
DebugAssert(i < self->numericValues->n);
DEBUG_ASSERT(i < self->numericValues->n);
while (self->numericValues->v[i]->v[0] == 1) {
self->bitmapCurrent++;
self->bitmapCurrentElementsDescriptorsIndex++;
@ -1813,7 +1813,7 @@ static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self,
self->bitmapCurrent++;
self->bitmapCurrentElementsDescriptorsIndex++;
i = self->bitmapCurrent + self->bitmapStart;
DebugAssert(i < numericValues->n);
DEBUG_ASSERT(i < numericValues->n);
while (numericValues->v[i] == 1) {
self->bitmapCurrent++;
self->bitmapCurrentElementsDescriptorsIndex++;
@ -1984,7 +1984,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr
operatorCreator.name = (char*)"operator";
if (attribute) {
DebugAssert(attribute->parent == NULL);
DEBUG_ASSERT(attribute->parent == NULL);
}
if (add_dump_flag) {
@ -2538,7 +2538,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset
if (descriptor->F == 0 && IS_COORDINATE_DESCRIPTOR(descriptor->X) &&
self->unpackMode == CODES_BUFR_UNPACK_STRUCTURE) {
const int sidx = descriptor->Y + significanceQualifierIndexArray[descriptor->X] * NUMBER_OF_QUALIFIERS_PER_CATEGORY;
DebugAssert(sidx > 0);
DEBUG_ASSERT(sidx > 0);
groupNumber++;
add_coord_flag = 1;
@ -2875,7 +2875,7 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st
decoding = 1;
do_clean = 1;
dataAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->bufrDataEncodedName);
DebugAssert(dataAccessor);
DEBUG_ASSERT(dataAccessor);
dataOffset = accessor_raw_get_offset(dataAccessor);
pos = dataOffset * 8;
codec_element = &decode_element;
@ -3036,7 +3036,7 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st
/* Delayed replication */
inr = numberOfNestedRepetitions;
numberOfNestedRepetitions++;
DebugAssert(numberOfNestedRepetitions <= MAX_NESTED_REPLICATIONS);
DEBUG_ASSERT(numberOfNestedRepetitions <= MAX_NESTED_REPLICATIONS);
numberOfElementsToRepeat[inr] = descriptors[i]->X;
n[inr] = numberOfElementsToRepeat[inr];
i++;

View File

@ -284,9 +284,9 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
grib_context* c = a->context;
if (self->compressedData) {
DebugAssert(self->index < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
idx = ((int)self->numericValues->v[self->index]->v[0] / 1000 - 1) / self->numberOfSubsets;
DebugAssert(idx < self->stringValues->n);
DEBUG_ASSERT(idx < self->stringValues->n);
count = grib_sarray_used_size(self->stringValues->v[idx]);
for (i = 0; i < count; i++) {
val[i] = grib_context_strdup(c, self->stringValues->v[idx]->v[i]);
@ -294,8 +294,8 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
*len = count;
}
else {
DebugAssert(self->subsetNumber < self->numericValues->n);
DebugAssert(self->index < self->numericValues->v[self->subsetNumber]->n);
DEBUG_ASSERT(self->subsetNumber < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n);
idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1;
val[0] = grib_context_strdup(c, self->stringValues->v[idx]->v[0]);
*len = 1;
@ -359,18 +359,18 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
}
if (self->compressedData) {
DebugAssert(self->index < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
idx = ((int)self->numericValues->v[self->index]->v[0] / 1000 - 1) / self->numberOfSubsets;
if (idx < 0)
return GRIB_INTERNAL_ERROR;
str = grib_context_strdup(c, self->stringValues->v[idx]->v[0]);
}
else {
DebugAssert(self->subsetNumber < self->numericValues->n);
DEBUG_ASSERT(self->subsetNumber < self->numericValues->n);
idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1;
if (idx < 0)
return GRIB_INTERNAL_ERROR;
DebugAssert(idx < self->stringValues->n);
DEBUG_ASSERT(idx < self->stringValues->n);
str = grib_context_strdup(c, self->stringValues->v[idx]->v[0]);
}
@ -440,15 +440,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (self->compressedData) {
for (i = 0; i < count; i++) {
DebugAssert(self->index < self->numericValues->n);
DebugAssert(i < self->numericValues->v[self->index]->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
DEBUG_ASSERT(i < self->numericValues->v[self->index]->n);
val[i] = self->numericValues->v[self->index]->v[i] == GRIB_MISSING_DOUBLE ? GRIB_MISSING_LONG : (long)self->numericValues->v[self->index]->v[i];
}
*len = count;
}
else {
DebugAssert(self->subsetNumber < self->numericValues->n);
DebugAssert(self->index < self->numericValues->v[self->subsetNumber]->n);
DEBUG_ASSERT(self->subsetNumber < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n);
val[0] = self->numericValues->v[self->subsetNumber]->v[self->index] == GRIB_MISSING_DOUBLE ? GRIB_MISSING_LONG : (long)self->numericValues->v[self->subsetNumber]->v[self->index];
*len = 1;
}
@ -469,15 +469,15 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (self->compressedData) {
for (i = 0; i < count; i++) {
DebugAssert(self->index < self->numericValues->n);
DebugAssert(i < self->numericValues->v[self->index]->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
DEBUG_ASSERT(i < self->numericValues->v[self->index]->n);
val[i] = self->numericValues->v[self->index]->v[i];
}
*len = count;
}
else {
DebugAssert(self->subsetNumber < self->numericValues->n);
DebugAssert(self->index < self->numericValues->v[self->subsetNumber]->n);
DEBUG_ASSERT(self->subsetNumber < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n);
val[0] = self->numericValues->v[self->subsetNumber]->v[self->index];
*len = 1;
}
@ -558,12 +558,12 @@ static int value_count(grib_accessor* a, long* count)
type = get_native_type(a);
if (type == GRIB_TYPE_STRING) {
DebugAssert(self->index < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
idx = ((int)self->numericValues->v[self->index]->v[0] / 1000 - 1) / self->numberOfSubsets;
size = grib_sarray_used_size(self->stringValues->v[idx]);
}
else {
DebugAssert(self->index < self->numericValues->n);
DEBUG_ASSERT(self->index < self->numericValues->n);
size = grib_darray_used_size(self->numericValues->v[self->index]);
}
@ -597,7 +597,7 @@ static int get_native_type(grib_accessor* a)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = GRIB_TYPE_DOUBLE;
DebugAssert(self);
DEBUG_ASSERT(self);
switch (self->type) {
case BUFR_DESCRIPTOR_TYPE_STRING:
ret = GRIB_TYPE_STRING;

View File

@ -241,7 +241,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
dictionary = grib_trie_new(c);
while (fgets(line, sizeof(line) - 1, f)) {
DebugAssert( strlen(line) > 0 );
DEBUG_ASSERT( strlen(line) > 0 );
if (line[0] == '#') continue; /* Ignore first line with column titles */
list = string_split(line, "|");
grib_trie_insert(dictionary, list[0], list);
@ -258,7 +258,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
}
while (fgets(line, sizeof(line) - 1, f)) {
DebugAssert( strlen(line) > 0 );
DEBUG_ASSERT( strlen(line) > 0 );
if (line[0] == '#') continue; /* Ignore first line with column titles */
list = string_split(line, "|");
/* Look for the descriptor code in the trie. It might be there from before */
@ -383,7 +383,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i
return NULL;
c = a->context;
DebugAssert(c);
DEBUG_ASSERT(c);
v = (bufr_descriptor*)grib_context_malloc_clear(c, sizeof(bufr_descriptor));
if (!v) {
grib_context_log(c, GRIB_LOG_ERROR,

View File

@ -124,7 +124,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* param)
static int test_bit(long a, long b)
{
DebugAssert(b>=0);
DEBUG_ASSERT(b>=0);
return a & (1 << b);
}

View File

@ -168,7 +168,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params)
grib_handle* hand = grib_handle_of_accessor(a);
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
grib_action* act = (grib_action*)(a->creator);
DebugAssert(len == self->nbytes);
DEBUG_ASSERT(len == self->nbytes);
if (new_len == 0) {
/* ECC-485: When the codetable length is 0, it means we are passing

View File

@ -363,7 +363,7 @@ static int grib_concept_apply(grib_accessor* a, const char* name)
grib_action* act = a->creator;
int nofail = action_concept_get_nofail(a);
DebugAssert(concepts);
DEBUG_ASSERT(concepts);
c = (grib_concept_value*)grib_trie_get(concepts->index, name);

View File

@ -230,17 +230,17 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (latitude_of_first_point == 0) {
for (i = 0; i < number_of_values; i++) {
DebugAssert(coded_vals);
DEBUG_ASSERT(coded_vals);
if (coded_vals) val[i] = coded_vals[i];
}
for (i = number_of_values; i < number_of_points; i++) {
DebugAssert(coded_vals);
DEBUG_ASSERT(coded_vals);
if (coded_vals) val[i] = coded_vals[number_of_values - 1];
}
}
else {
for (i = 0; i < ni - 1; i++) {
DebugAssert(coded_vals);
DEBUG_ASSERT(coded_vals);
if (coded_vals) val[i] = coded_vals[0];
}
for (i = ni - 1; i < number_of_points; i++) {

View File

@ -330,7 +330,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
if (reference_value > min) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min);
DebugAssert(reference_value <= min);
DEBUG_ASSERT(reference_value <= min);
return GRIB_INTERNAL_ERROR;
}
}

View File

@ -901,7 +901,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
maxA = X[count];
minA = X[count];
for (i = 1; i < groupLengthA; i++) {
DebugAssertAccess(X, count + i, numberOfValues);
DEBUG_ASSERT_ACCESS(X, count + i, numberOfValues);
if (maxA < X[count + i])
maxA = X[count + i];
if (minA > X[count + i])
@ -933,7 +933,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
maxC = X[offsetC];
minC = X[offsetC];
for (i = 1; i < groupLengthC; i++) {
DebugAssertAccess(X, offsetC + i, numberOfValues);
DEBUG_ASSERT_ACCESS(X, offsetC + i, numberOfValues);
if (maxC < X[offsetC + i])
maxC = X[offsetC + i];
if (minC > X[offsetC + i])

View File

@ -662,7 +662,7 @@ static int unpack(grib_accessor* a, T* val, const size_t* len)
if (missingValueManagementUsed == 0) {
// No explicit missing values included within data values
for (j = 0; j < nvals_per_group; j++) {
DebugAssertAccess(sec_val, (long)(vcount + j), n_vals);
DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals);
sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val);
// printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]);
}

View File

@ -418,8 +418,8 @@ static double laplam(bif_trunc_t* bt, const double val[])
else {
int m, ll = itab1[i * i + j * j];
for (m = 0; m < 4; m++, isp++) {
DebugAssertAccess(znorm, (long)ll, (long)lmax);
DebugAssertAccess(val, (long)isp, (long)bt->n_vals_bif);
DEBUG_ASSERT_ACCESS(znorm, (long)ll, (long)lmax);
DEBUG_ASSERT_ACCESS(val, (long)isp, (long)bt->n_vals_bif);
if (ll < lmax && isp < bt->n_vals_bif) {
znorm[ll] = std::max(znorm[ll], fabs(val[isp]));
}

View File

@ -176,7 +176,7 @@ static int pre_processing_func(double* values, long length, long pre_processing,
if (min > 0) {
*pre_processing_parameter = 0;
for (i = 0; i < length; i++) {
DebugAssert(values[i] > 0);
DEBUG_ASSERT(values[i] > 0);
values[i] = log(values[i]);
}
}
@ -187,7 +187,7 @@ static int pre_processing_func(double* values, long length, long pre_processing,
return ret;
ppp = *pre_processing_parameter;
for (i = 0; i < length; i++) {
DebugAssert((values[i] + ppp) > 0);
DEBUG_ASSERT((values[i] + ppp) > 0);
values[i] = log(values[i] + ppp);
}
}

View File

@ -679,11 +679,11 @@ static int expand(grib_accessor* a)
if (aDescriptor1->F == 2 && aDescriptor1->X == 6) {
Assert(aDescriptor1->type == BUFR_DESCRIPTOR_TYPE_OPERATOR);
operator206yyy_width = aDescriptor1->Y; /* Store the width for the following descriptor */
DebugAssert(operator206yyy_width > 0);
DEBUG_ASSERT(operator206yyy_width > 0);
}
else if (operator206yyy_width > 0) {
if (err == GRIB_NOT_FOUND) {
DebugAssert(aDescriptor1->type == BUFR_DESCRIPTOR_TYPE_UNKNOWN);
DEBUG_ASSERT(aDescriptor1->type == BUFR_DESCRIPTOR_TYPE_UNKNOWN);
err = 0; /* Clear any error generated due to local descriptor */
aDescriptor1->nokey = aDescriptor2->nokey = 1; /* Do not show this descriptor in dump */
}

View File

@ -176,7 +176,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
NS = (MS + 1) * (MS + 2);
if (bpv != 0) {
DebugAssert(offsetAfterData > offsetBeforeData);
DEBUG_ASSERT(offsetAfterData > offsetBeforeData);
*val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits + NS * (bpv - 32)) / bpv;
}
else {

View File

@ -152,7 +152,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
return ret;
if (bpv != 0) {
DebugAssert(offsetAfterData > offsetBeforeData);
DEBUG_ASSERT(offsetAfterData > offsetBeforeData);
*val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv;
}
else {

View File

@ -164,7 +164,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
/*TODO implement the dirty mechanism to avoid to unpack every time */
err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size);
if (err) return err;
DebugAssert(size > 0);
DEBUG_ASSERT(size > 0);
vector = (long*)grib_context_malloc(a->context, sizeof(long) * size);
err = grib_unpack_long(va, vector, &size);
grib_context_free(a->context, vector);

View File

@ -155,7 +155,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (bpv != 0) {
grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData, offsetBeforeData, unusedBits, bpv);
DebugAssert(offsetAfterData > offsetBeforeData);
DEBUG_ASSERT(offsetAfterData > offsetBeforeData);
*val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv;
}
else {

View File

@ -118,16 +118,6 @@ grib_accessor_class* grib_accessor_class_second_order_bits_per_value = &_grib_ac
/* END_CLASS_IMP */
/*
static const size_t nbits[32]={
0x1, 0x2, 0x4, 0x8, 0x10, 0x20,
0x40, 0x80, 0x100, 0x200, 0x400, 0x800,
0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000,
0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000,
0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, 0x20000000,
0x40000000, 0x80000000
};
*/
static const size_t nbits[64] = {
0x1, 0x2, 0x4, 0x8,
0x10, 0x20, 0x40, 0x80,

View File

@ -351,13 +351,13 @@ static int grib_load_smart_table(grib_context* c, const char* filename,
numberOfColumns = 0;
/* The highest possible descriptor code must fit into t->numberOfEntries */
DebugAssert(code < t->numberOfEntries);
DEBUG_ASSERT(code < t->numberOfEntries);
while (*s) {
char* tcol = t->entries[code].column[numberOfColumns];
if ( tcol ) grib_context_free_persistent(c, tcol);
t->entries[code].column[numberOfColumns] = grib_context_strdup_persistent(c, s);
numberOfColumns++;
DebugAssert(numberOfColumns < MAX_SMART_TABLE_COLUMNS);
DEBUG_ASSERT(numberOfColumns < MAX_SMART_TABLE_COLUMNS);
p++;
s = p;

View File

@ -121,8 +121,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* arg)
self->input = grib_arguments_get_name(h, arg, n++);
self->trim_left = grib_arguments_get_long(h, arg, n++);
self->trim_right= grib_arguments_get_long(h, arg, n++);
DebugAssert(self->trim_left == 0 || self->trim_left == 1);
DebugAssert(self->trim_right == 0 || self->trim_right == 1);
DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1);
DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1);
}
static int unpack_string(grib_accessor* a, char* val, size_t* len)

View File

@ -186,8 +186,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
#endif
#ifdef DEBUG
#define DebugAssert(a) Assert(a)
#define DebugAssertAccess(array, index, size) \
#define DEBUG_ASSERT(a) Assert(a)
#define DEBUG_ASSERT_ACCESS(array, index, size) \
do { \
if (!((index) >= 0 && (index) < (size))) { \
printf("ARRAY ACCESS ERROR: array=%s idx=%ld size=%ld @ %s +%d \n", #array, index, size, __FILE__, __LINE__); \
@ -195,8 +195,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
} \
} while (0)
#else
#define DebugAssert(a)
#define DebugAssertAccess(array, index, size)
#define DEBUG_ASSERT(a)
#define DEBUG_ASSERT_ACCESS(array, index, size)
#endif
/* Return true if two strings are equal */

View File

@ -60,7 +60,7 @@ static void init_bits_all_one()
int size = sizeof(int64_t) * 8;
int64_t* v = 0;
uint64_t cmask = -1;
DebugAssert(!bits_all_one.inited);
DEBUG_ASSERT(!bits_all_one.inited);
bits_all_one.size = size;
bits_all_one.inited = 1;
@ -131,7 +131,7 @@ int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberO
*bitOffset += numberOfCharacters * 8;
return err;
}
DebugAssert(remainderComplement >= 0);
DEBUG_ASSERT(remainderComplement >= 0);
for (i = 0; i < numberOfCharacters; i++) {
c = ((*s) >> remainder) & ~mask[remainder];
*p |= c;
@ -169,7 +169,7 @@ char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t
return string;
}
DebugAssert(remainderComplement >= 0);
DEBUG_ASSERT(remainderComplement >= 0);
for (i = 0; i < numberOfCharacters; i++) {
c = (*p) << remainder;
p++;
@ -242,7 +242,7 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long
while (bitsToRead > 0) {
ret <<= 8;
/* ret += p[pi]; */
DebugAssert((ret & p[pi]) == 0);
DEBUG_ASSERT((ret & p[pi]) == 0);
ret = ret | p[pi];
pi++;
bitsToRead -= usefulBitsInByte;
@ -366,7 +366,7 @@ size_t grib_decode_size_t(const unsigned char* p, long* bitp, long nbits)
while (bitsToRead > 0) {
ret <<= 8;
/* ret += p[pi]; */
DebugAssert((ret & p[pi]) == 0);
DEBUG_ASSERT((ret & p[pi]) == 0);
ret = ret | p[pi];
pi++;
bitsToRead -= usefulBitsInByte;

View File

@ -233,8 +233,8 @@ void grib_buffer_replace(grib_accessor* a, const unsigned char* data,
message_length - offset - oldsize);
/* copy new data */
DebugAssert(buffer->data + offset);
DebugAssert(data || (newsize == 0)); /* if data==NULL then newsize must be 0 */
DEBUG_ASSERT(buffer->data + offset);
DEBUG_ASSERT(data || (newsize == 0)); /* if data==NULL then newsize must be 0 */
if (data) {
/* Note: memcpy behaviour is undefined if either dest or src is NULL */
memcpy(buffer->data + offset, data, newsize);

View File

@ -50,7 +50,7 @@ bufr_descriptor* grib_bufr_descriptors_array_pop_front(bufr_descriptors_array* a
{
bufr_descriptor* v = a->v[0];
if (a->n == 0) {
DebugAssert(0);
DEBUG_ASSERT(0);
}
a->n--;
a->v++;

View File

@ -26,7 +26,7 @@ grib_handle* grib_handle_of_accessor(const grib_accessor* a)
static grib_handle* handle_of(grib_accessor* observed)
{
grib_handle* h = NULL;
DebugAssert(observed);
DEBUG_ASSERT(observed);
/* printf("+++++ %s->parent = %p\n",observed->name,observed->parent); */
/* printf("+++++ %s = %p\n",observed->name,observed); */
/* printf("+++++ h=%p\n",observed->h); */

View File

@ -315,9 +315,9 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
/* Note: the "subsetNumber" key is only there for UNCOMPRESSED BUFR messages */
if (self->numberOfSubsets > 1 && strcmp(a->name, "subsetNumber") == 0) {
err = grib_unpack_long(a, &value, &size);
DebugAssert(!err);
DEBUG_ASSERT(!err);
fprintf(self->dumper.out, "%s=%ld\n", a->name, value);
DebugAssert(!grib_is_missing_long(a, value));
DEBUG_ASSERT(!grib_is_missing_long(a, value));
(void)err;
return;
}

View File

@ -290,7 +290,7 @@ void grib_file_pool_delete_file(grib_file* file)
break;
prev = prev->next;
}
DebugAssert(prev);
DEBUG_ASSERT(prev);
if (prev) {
prev->next = file->next;
}

View File

@ -769,7 +769,7 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc_clear(c, sizeof(unsigned char) * gtslen);
DebugAssert(gts_header);
DEBUG_ASSERT(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);
@ -1002,7 +1002,7 @@ grib_handle* bufr_new_from_file(grib_context* c, FILE* f, int* error)
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc(c, sizeof(unsigned char) * gtslen);
DebugAssert(gts_header);
DEBUG_ASSERT(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);
@ -1125,7 +1125,7 @@ static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f,
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc(c, sizeof(unsigned char) * gtslen);
DebugAssert(gts_header);
DEBUG_ASSERT(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);

View File

@ -217,7 +217,7 @@ long* grib_iarray_get_array(grib_iarray* v)
long* vv;
size_t i;
grib_context* c = v->context;
DebugAssert(c);
DEBUG_ASSERT(c);
vv = (long*)grib_context_malloc_clear(c, sizeof(long) * v->n);
for (i = 0; i < v->n; i++)

View File

@ -330,7 +330,7 @@ int grib_nearest_smaller_ieee_float(double a, double* ret)
unsigned long grib_ieee64_to_long(double x)
{
unsigned long lval;
DebugAssert(sizeof(double) == sizeof(long));
DEBUG_ASSERT(sizeof(double) == sizeof(long));
memcpy(&lval, &x, sizeof(long));
return lval;
}
@ -338,7 +338,7 @@ unsigned long grib_ieee64_to_long(double x)
double grib_long_to_ieee64(unsigned long x)
{
double dval;
DebugAssert(sizeof(double) == sizeof(long));
DEBUG_ASSERT(sizeof(double) == sizeof(long));
memcpy(&dval, &x, sizeof(long));
return dval;
}

View File

@ -148,7 +148,7 @@ static int init(grib_iterator* i, grib_handle* h, grib_arguments* args)
if (jScansPositively) {
for (lai = 0; lai < self->Nj; lai++) {
DebugAssert(istart >= 0);
DEBUG_ASSERT(istart >= 0);
self->las[lai] = lats[istart--];
if (istart<0) istart=size-1;
}

View File

@ -253,7 +253,7 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
return GRIB_WRONG_GRID;
}
self->los[iter->e] = lon2;
DebugAssert(j + l < numlats);
DEBUG_ASSERT(j + l < numlats);
self->las[iter->e] = lats[j + l];
iter->e++;
}

View File

@ -361,7 +361,7 @@ static int init_oblate(grib_handle* h,
}
lonRad = adjust_lon_radians(theta / ns + LoVInRadians);
if (i == 0 && j == 0) {
DebugAssert(fabs(latFirstInRadians - latRad) <= EPSILON);
DEBUG_ASSERT(fabs(latFirstInRadians - latRad) <= EPSILON);
}
latDeg = latRad * RAD2DEG; /* Convert to degrees */
lonDeg = normalise_longitude_in_degrees(lonRad * RAD2DEG);

View File

@ -217,7 +217,7 @@ static int init_mercator(grib_handle* h,
}
lonRad = adjust_lon_radians(orientationInRadians + _x / (earthMajorAxisInMetres * m1));
if (i == 0 && j == 0) {
DebugAssert(fabs(latFirstInRadians - latRad) <= EPSILON);
DEBUG_ASSERT(fabs(latFirstInRadians - latRad) <= EPSILON);
}
latDeg = latRad * RAD2DEG; /* Convert to degrees */
lonDeg = normalise_longitude_in_degrees(lonRad * RAD2DEG);

View File

@ -112,7 +112,7 @@ void** grib_oarray_get_array(grib_context* c, grib_oarray* v)
void* grib_oarray_get(grib_oarray* v, int i)
{
DebugAssert(i >= 0);
DEBUG_ASSERT(i >= 0);
if (v == NULL || (size_t)i > v->n - 1)
return NULL;
return v->v[i];

View File

@ -314,7 +314,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha
char long_format[] = "%ld"; /* default format for printing integer keys */
char default_separator[] = " ";
grib_accessor* a = al->accessor;
DebugAssert(a);
DEBUG_ASSERT(a);
/* Number of columns specified as 0 means print on ONE line i.e. num cols = infinity */
if (maxcols == 0)

View File

@ -78,7 +78,7 @@ static void rebuild_hash_keys(grib_handle* h, grib_section* s)
int i = 0;
int id = -1;
const char* p;
DebugAssert(h == grib_handle_of_accessor(a));
DEBUG_ASSERT(h == grib_handle_of_accessor(a));
while (i < MAX_ACCESSOR_NAMES && ((p = a->all_names[i]) != NULL)) {
if (*p != '_') {
@ -88,7 +88,7 @@ static void rebuild_hash_keys(grib_handle* h, grib_section* s)
grib_handle* hand = grib_handle_of_accessor(a);
a->same = hand->accessors[id];
hand->accessors[id] = a;
DebugAssert(a->same != a);
DEBUG_ASSERT(a->same != a);
}
}
i++;
@ -149,7 +149,7 @@ static char* get_rank(grib_context* c, const char* name, int* rank)
*rank = -1;
}
else {
DebugAssert(c);
DEBUG_ASSERT(c);
end++;
ret = grib_context_strdup(c, end);
}
@ -521,7 +521,7 @@ static grib_accessor* _grib_find_accessor(const grib_handle* ch, const char* nam
grib_handle* h = (grib_handle*)ch;
grib_accessor* a = NULL;
char* p = NULL;
DebugAssert(name);
DEBUG_ASSERT(name);
p = strchr((char*)name, '.');
if (p) {
@ -614,7 +614,7 @@ grib_accessor* grib_find_accessor_fast(grib_handle* h, const char* name)
{
grib_accessor* a = NULL;
char* p = NULL;
DebugAssert(name);
DEBUG_ASSERT(name);
p = strchr((char*)name, '.');
if (p) {

View File

@ -92,7 +92,7 @@ static grib_handle* try_product_template(grib_context* c, ProductKind product_ki
g = codes_bufr_handle_new_from_file(c, f, &err);
} else {
/* Note: Pseudo GRIBs like DIAG and BUDG also come here */
DebugAssert(product_kind == PRODUCT_GRIB);
DEBUG_ASSERT(product_kind == PRODUCT_GRIB);
g = grib_handle_new_from_file(c, f, &err);
}
if (!g) {

View File

@ -361,7 +361,7 @@ static void grib_trie_with_rank_delete_container_list(grib_context* c,grib_trie_
static void _grib_trie_with_rank_delete_container(grib_trie_with_rank* t)
{
int i;
DebugAssert(t);
DEBUG_ASSERT(t);
for (i = t->first; i <= t->last; i++)
if (t->next[i]) {
grib_trie_with_rank_delete_container(t->next[i]);
@ -453,7 +453,7 @@ int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* da
{
grib_trie_with_rank* last = t;
const char* k = key;
DebugAssert(t);
DEBUG_ASSERT(t);
if (!t) return -1;
GRIB_MUTEX_INIT_ONCE(&once, &init);

View File

@ -1240,7 +1240,7 @@ int grib_get_native_type(const grib_handle* h, const char* name, int* type)
grib_accessor* a = NULL;
*type = GRIB_TYPE_UNDEFINED;
DebugAssert(name != NULL && strlen(name) > 0);
DEBUG_ASSERT(name != NULL && strlen(name) > 0);
if (name[0] == '/') {
al = grib_find_accessors_list(h, name);

View File

@ -40,7 +40,7 @@ void string_rtrim(char* s)
void string_lrtrim(char** x, int do_left, int do_right)
{
DebugAssert(do_left || do_right);
DEBUG_ASSERT(do_left || do_right);
if (do_left) {
while (isspace(**x) && **x != '\0')
(*x)++;
@ -91,8 +91,8 @@ char** string_split(char* inputString, const char* delimiter)
size_t index = 0;
char delimiterChar = 0;
DebugAssert(inputString);
DebugAssert(delimiter && (strlen(delimiter) == 1));
DEBUG_ASSERT(inputString);
DEBUG_ASSERT(delimiter && (strlen(delimiter) == 1));
delimiterChar = delimiter[0];
while (*p) {
const char ctmp = *p;
@ -165,7 +165,7 @@ int string_ends_with(const char* s, const char* suffix)
int string_count_char(const char* str, char c)
{
int i = 0, count = 0;
DebugAssert(str);
DEBUG_ASSERT(str);
for (i=0; str[i]; i++) {
if (str[i] == c) count++;
}
@ -225,7 +225,7 @@ char* string_replace_char(char *s, char oldc, char newc)
void string_remove_char(char* str, char c)
{
size_t i, j;
DebugAssert(str);
DEBUG_ASSERT(str);
size_t len = strlen(str);
for(i=0; i<len; i++) {
if(str[i] == c) {

View File

@ -652,7 +652,7 @@ static char* get_keyname_without_rank(const char* name)
if (*p == '#') {
strtol(++p, &pEnd, 10);
if (*pEnd != '#') {
DebugAssert(!"Badly formed rank in key");
DEBUG_ASSERT(!"Badly formed rank in key");
}
else {
/* Take everything after 2nd '#' */

View File

@ -66,7 +66,7 @@ int grib_tool_before_getopt(grib_runtime_options* options)
*/
int grib_tool_init(grib_runtime_options* options)
{
DebugAssert(!options->latlon);
DEBUG_ASSERT(!options->latlon);
return 0;
}

View File

@ -662,7 +662,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
printf(" comparing %s", name);
/* If key was blocklisted, then we should not have got here */
DebugAssert(!blocklisted(name));
DEBUG_ASSERT(!blocklisted(name));
if (type1 == GRIB_TYPE_UNDEFINED && (err = grib_get_native_type(h1, name, &type1)) != GRIB_SUCCESS) {
printInfo(h1);

View File

@ -2245,7 +2245,7 @@ static int def_latlon(int ncid, fieldset* fs)
field* g = get_field(fs, 0, expand_mem);
DebugAssert(check_grid(g) == GRIB_SUCCESS);
DEBUG_ASSERT(check_grid(g) == GRIB_SUCCESS);
if ((e = get_num_latitudes_longitudes(g->handle, &nlats, &nlons)) != GRIB_SUCCESS) {
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get lat/lon info: %s", grib_get_error_message(e));
@ -2629,8 +2629,8 @@ static void scale(double* vals, long n, void* data, dataset_t* g)
return;
}
*/
DebugAssert(vals);
DebugAssert(n > 0);
DEBUG_ASSERT(vals);
DEBUG_ASSERT(n > 0);
if (!vals) return;
switch (nctype) {