Refactoring

This commit is contained in:
Shahram Najm 2021-01-16 12:51:17 +00:00
parent b01cbf88c9
commit e96436844b
3 changed files with 52 additions and 58 deletions

View File

@ -98,7 +98,7 @@ void grib_dump(grib_action* a, FILE* f, int l)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
}
void grib_xref(grib_action* a, FILE* f, const char* path)
@ -114,7 +114,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);
Assert(0);
DebugAssert(0);
}
@ -147,7 +147,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);
Assert(0);
DebugAssert(0);
return 0;
}
@ -168,7 +168,7 @@ int grib_action_notify_change(grib_action* a, grib_accessor* observer, grib_acce
c = c->super ? *(c->super) : NULL;
}
/*GRIB_MUTEX_UNLOCK(&mutex1);*/
Assert(0);
DebugAssert(0);
return 0;
}
@ -181,7 +181,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;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -194,7 +194,7 @@ int grib_action_execute(grib_action* a, grib_handle* h)
return c->execute(a, h);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}

View File

@ -39,7 +39,7 @@ void grib_accessor_dump(grib_accessor* a, grib_dumper* f)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
}
int grib_pack_missing(grib_accessor* a)
@ -52,7 +52,7 @@ int grib_pack_missing(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -66,7 +66,7 @@ int grib_pack_zero(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -80,7 +80,7 @@ int grib_is_missing_internal(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -94,7 +94,7 @@ int grib_pack_double(grib_accessor* a, const double* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -108,7 +108,7 @@ int grib_pack_expression(grib_accessor* a, grib_expression* e)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -122,7 +122,7 @@ int grib_pack_string(grib_accessor* a, const char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -136,7 +136,7 @@ int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -150,7 +150,7 @@ int grib_pack_long(grib_accessor* a, const long* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -164,7 +164,7 @@ int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -178,7 +178,7 @@ int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -191,7 +191,7 @@ int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -205,7 +205,7 @@ int grib_unpack_double(grib_accessor* a, double* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -231,7 +231,7 @@ int grib_unpack_string(grib_accessor* a, char* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -244,7 +244,7 @@ int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -309,7 +309,7 @@ int grib_unpack_long(grib_accessor* a, long* v, size_t* len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -324,7 +324,7 @@ long grib_accessor_get_native_type(grib_accessor* a)
return c->get_native_type(a);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -340,7 +340,7 @@ long grib_get_next_position_offset(grib_accessor* a)
return c->next_offset(a);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -355,7 +355,7 @@ long grib_string_length(grib_accessor* a)
return c->string_length(a);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -370,7 +370,7 @@ long grib_byte_offset(grib_accessor* a)
return c->byte_offset(a);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -385,7 +385,7 @@ long grib_byte_count(grib_accessor* a)
return c->byte_count(a);
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -403,7 +403,7 @@ int grib_value_count(grib_accessor* a, long* count)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -432,7 +432,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);
Assert(0);
DebugAssert(0);
return 0;
}
@ -507,7 +507,7 @@ void grib_update_size(grib_accessor* a, size_t len)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
}
int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
@ -519,7 +519,7 @@ int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -534,7 +534,7 @@ size_t grib_preferred_size(grib_accessor* a, int from_handle)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -547,7 +547,7 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return 0;
}
@ -562,7 +562,7 @@ void grib_resize(grib_accessor* a, size_t new_size)
}
c = c->super ? *(c->super) : NULL;
}
Assert(0);
DebugAssert(0);
return;
}

View File

@ -200,12 +200,12 @@ static const char* aec_get_error_message(int code)
}
static void print_aec_stream_info(struct aec_stream* strm, const char* func)
{
fprintf(stderr, "ECCODES DEBUG CCSDS %s flags=%u\n", func, strm->flags);
fprintf(stderr, "ECCODES DEBUG CCSDS %s bits_per_sample=%u\n", func, strm->bits_per_sample);
fprintf(stderr, "ECCODES DEBUG CCSDS %s block_size=%u\n", func, strm->block_size);
fprintf(stderr, "ECCODES DEBUG CCSDS %s rsi=%u\n", func, strm->rsi);
fprintf(stderr, "ECCODES DEBUG CCSDS %s avail_out=%lu\n", func, strm->avail_out);
fprintf(stderr, "ECCODES DEBUG CCSDS %s avail_in=%lu\n", func, strm->avail_in);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.bits_per_sample=%u\n", func, strm->bits_per_sample);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.rsi=%u\n", func, strm->rsi);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_out=%lu\n", func, strm->avail_out);
fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in);
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
@ -213,15 +213,14 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
grib_handle* hand = grib_handle_of_accessor(a);
int err = GRIB_SUCCESS;
int i;
int err = GRIB_SUCCESS, i = 0;
size_t buflen = grib_byte_count(a);
struct aec_stream strm;
double bscale = 0;
double dscale = 0;
unsigned char* buf = NULL;
size_t n_vals = 0;
size_t size;
size_t size = 0;
unsigned char* decoded = NULL;
unsigned char* p = NULL;
long pos = 0;
@ -325,8 +324,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
grib_handle* hand = grib_handle_of_accessor(a);
int err = GRIB_SUCCESS;
int i;
int err = GRIB_SUCCESS, i = 0;
size_t buflen = 0;
unsigned char* buf = NULL;
@ -337,15 +335,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long binary_scale_factor = 0;
long decimal_scale_factor = 0;
double reference_value = 0;
long bits8;
long bits_per_value = 0;
double max, min;
double d;
long bits8 = 0;
long bits_per_value = 0;
double max, min, d, divisor;
unsigned char* p;
double divisor;
long number_of_data_points;
long ccsds_flags;
@ -382,12 +376,12 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
return GRIB_SUCCESS;
}
if (bits_per_value == 0) {
int i;
/* constant field */
for (i = 1; i < n_vals; i++)
if (bits_per_value == 0) { /* constant field */
#ifdef DEBUG
for (i = 1; i < n_vals; i++) {
Assert(val[i] == val[0]);
}
#endif
if ((err = grib_set_double_internal(hand, self->reference_value, val[0])) != GRIB_SUCCESS)
return err;
{
@ -458,7 +452,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
buflen++;
}
}
/* buflen = n_vals*(bits_per_value/8);*/
/* buflen = n_vals*(bits_per_value/8);*/
grib_context_log(a->context, GRIB_LOG_DEBUG,
"CCSDS pack_double: packing %s, %d values", a->name, n_vals);