Dead code removal and cleanup

This commit is contained in:
Shahram Najm 2023-06-27 16:35:52 +01:00
parent 5ab521e9e6
commit 149fd27410
7 changed files with 9 additions and 98 deletions

View File

@ -593,53 +593,6 @@ static void destroy(grib_context* c, grib_accessor* a)
//grib_context_free(c,self->cval);
}
// static int is_local_ecmwf_grib2_param_key(grib_accessor* a, long edition, long centre)
// {
// if (edition == 2 && centre == 98) {
// if (a->parent->owner && a->parent->owner->name && strcmp(a->parent->owner->name, "parameters") == 0)
// return 1;
// }
// return 0;
// }
// /* Try to get the name, shortName, units etc for a GRIB2 message with
// * local ECMWF coding i.e. discipline=192 etc
// */
// static const char* get_ECMWF_local_parameter(grib_accessor* a, grib_handle* h)
// {
// int err = 0;
// const char* key_name = a->name; /*this is the key whose value we want*/
// long edition, centre;
// if (h->product_kind != PRODUCT_GRIB)
// return NULL;
// err = grib_get_long(h, "centre", &centre);
// if (err)
// return NULL;
// err = grib_get_long(h, "edition", &edition);
// if (err)
// return NULL;
// if (is_local_ecmwf_grib2_param_key(a, edition, centre)) {
// /* Must be one of: 'name', 'shortName', 'units', 'cfName' etc */
// grib_accessor* a2 = NULL;
// const long pid_guess = guess_paramId(h);
// if (pid_guess == -1)
// return NULL;
// /* Change the paramId so we can get the other string key*/
// err = grib_set_long(h, "paramId", pid_guess);
// if (err)
// return NULL;
// /* Get the string value of key. Do not call grib_get_string() to avoid
// * dangers of infinite recursion as that calls unpack_string()!
// */
// a2 = grib_find_accessor(h, key_name);
// if (!a2)
// return NULL;
// return concept_evaluate(a2);
// }
// return NULL;
// }
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
size_t slen;

View File

@ -133,26 +133,6 @@ static const unsigned char bitsoff[] = {
0
};
/*
static const unsigned char bitson[]={
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1,
2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2,
2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3,
4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3,
2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3,
4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4,
4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5,
6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4,
2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3,
4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4,
4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5,
6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5,
4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5,
6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6,
6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7,
8 };
*/
static void init(grib_accessor* a, const long len, grib_arguments* arg)
{
int n = 0;

View File

@ -837,10 +837,9 @@ static int value_count(grib_accessor* a, long* rlen)
static void destroy(grib_context* c, grib_accessor* a)
{
/* grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; */
/* if (self->rank==0 && self->expanded) { */
/* grib_bufr_descriptors_array_delete(self->expanded); */
/* } */
// grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
// if (self->rank==0 && self->expanded)
// grib_bufr_descriptors_array_delete(self->expanded);
}
static int get_native_type(grib_accessor* a)

View File

@ -200,10 +200,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
/* Do not do the length checks in this special case */
if ((ret = pack_long_unsigned_helper(a, &tlen, len, /*check=*/0)) != GRIB_SUCCESS)
return ret;
/*
if((ret = super->pack_long(a,&tlen,len)) != GRIB_SUCCESS)
return ret;
*/
// if((ret = super->pack_long(a,&tlen,len)) != GRIB_SUCCESS) return ret;
{
long total_length = -1, sec4_length = -1;

View File

@ -293,10 +293,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
}
}
/*ret = grib_set_long_internal(hand, self->numberOfPoints,numberOfPoints);
if(ret)
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
*/
//ret = grib_set_long_internal(hand, self->numberOfPoints,numberOfPoints);
//if(ret) grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
grib_get_long_internal(hand, self->numberOfPoints, &codedNumberOfPoints);

View File

@ -346,21 +346,6 @@ static long byte_count(grib_accessor* a)
return a->length;
}
/* NOT ANY MORE
static long byte_count(grib_accessor* a) {
grib_accessor_variable *self = (grib_accessor_variable*)a;
char buf[80]={0,};
if(self->type == GRIB_TYPE_STRING) {
return strlen(self->cval) +1;
} else {
snprintf(buf,64,"%g",self->dval);
printf("========> \"%s\"\n",buf);
return strlen(buf)+1;
}
}
*/
static int compare(grib_accessor* a, grib_accessor* b)
{
int retval = 0;

View File

@ -51,8 +51,7 @@ struct accessor_class_hash { char *name; grib_accessor_class **cclass;};
#endif
#endif
static unsigned int
grib_accessor_classes_get_id (const char *str, size_t len)
static unsigned int grib_accessor_classes_get_id (const char *str, size_t len)
{
static const unsigned short asso_values[] =
{
@ -687,8 +686,7 @@ static const struct accessor_class_hash classes[] =
{"g1forecastmonth", &grib_accessor_class_g1forecastmonth}
};
static const struct accessor_class_hash *
grib_accessor_classes_hash (const char *str, size_t len)
static const struct accessor_class_hash* grib_accessor_classes_hash (const char *str, size_t len)
{
unsigned int key = grib_accessor_classes_get_id (str, len);