Dead code removal

This commit is contained in:
Shahram Najm 2023-12-10 14:04:56 +00:00
parent 18d42c859f
commit 0c614bc926
3 changed files with 36 additions and 41 deletions

View File

@ -176,9 +176,9 @@ void grib_hash_array_value_delete(grib_context* c, grib_hash_array_value* v);
/* grib_bufr_descriptor.cc*/
bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err);
bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d);
int grib_bufr_descriptor_set_code(grib_accessor* tables_accessor, int code, bufr_descriptor* v);
int grib_bufr_descriptor_set_code(bufr_descriptor* v, int code);
void grib_bufr_descriptor_set_scale(bufr_descriptor* v, long scale);
int grib_bufr_descriptor_can_be_missing(bufr_descriptor* v);
int grib_bufr_descriptor_can_be_missing(const bufr_descriptor* v);
void grib_bufr_descriptor_delete(bufr_descriptor* v);
/* grib_bufr_descriptors_array.cc*/

View File

@ -343,7 +343,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
*err = GRIB_DECODING_ERROR;
return;
}
grib_bufr_descriptor_set_code(0, (size - 1) * 1000 + 100000, uidx);
grib_bufr_descriptor_set_code(uidx, (size - 1) * 1000 + 100000);
size++;
}
else {
@ -602,7 +602,7 @@ static int expand(grib_accessor* a)
bufr_descriptors_array* unexpanded_copy = NULL;
bufr_descriptors_array* expanded = NULL;
grib_context* c = a->context;
grib_handle* h = grib_handle_of_accessor(a);
const grib_handle* h = grib_handle_of_accessor(a);
int operator206yyy_width = 0; /* width specified by operator 206YYY */
if (!self->do_expand) {
@ -813,7 +813,7 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len)
char buf[25] = {0,};
long llen = 0;
size_t i = 0, size = 0;
grib_context* c = a->context;
const grib_context* c = a->context;
err = grib_value_count(a, &llen);
if (err) return err;

View File

@ -48,45 +48,40 @@ bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d)
return cd;
}
int grib_bufr_descriptor_set_code(grib_accessor* tables_accessor, int code, bufr_descriptor* v)
int grib_bufr_descriptor_set_code(bufr_descriptor* v, int code)
{
int err = 0;
bufr_descriptor* d;
if (!v) return GRIB_NULL_POINTER;
Assert(v->type == BUFR_DESCRIPTOR_TYPE_REPLICATION || v->type == BUFR_DESCRIPTOR_TYPE_OPERATOR);
if (!v)
return GRIB_NULL_POINTER;
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);
v->X = (code - v->F * 100000) / 1000;
v->Y = (code - v->F * 100000) % 1000;
if (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);
v->X = (code - v->F * 100000) / 1000;
v->Y = (code - v->F * 100000) % 1000;
}
else {
if (tables_accessor == NULL)
return GRIB_NULL_POINTER;
d = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, &err);
v->code = d->code;
v->F = d->F;
v->X = d->X;
v->Y = d->Y;
/* grib_context_free(c,v->name); See ECC-489 */
/* v->name=grib_context_strdup(c,d->name); See ECC-489 */
return GRIB_SUCCESS;
strcpy(v->shortName,d->shortName);
strcpy(v->units,d->units);
v->scale = d->scale;
v->factor = d->factor;
v->width = d->width;
v->reference = d->reference;
v->type = d->type;
v->nokey = d->nokey;
grib_bufr_descriptor_delete(d);
}
return err;
// Old implementation also had a "grib_accessor* tables_accessor" argument:
// if (tables_accessor == NULL)
// return GRIB_NULL_POINTER;
// bufr_descriptor* d = accessor_bufr_elements_table_get_descriptor(tables_accessor, code, &err);
// v->code = d->code;
// v->F = d->F;
// v->X = d->X;
// v->Y = d->Y;
// /* grib_context_free(c,v->name); See ECC-489 */
// /* v->name=grib_context_strdup(c,d->name); See ECC-489 */
// strcpy(v->shortName,d->shortName);
// strcpy(v->units,d->units);
// v->scale = d->scale;
// v->factor = d->factor;
// v->width = d->width;
// v->reference = d->reference;
// v->type = d->type;
// v->nokey = d->nokey;
// grib_bufr_descriptor_delete(d);
// return err;
}
void grib_bufr_descriptor_set_scale(bufr_descriptor* v, long scale)
@ -99,7 +94,7 @@ void grib_bufr_descriptor_set_scale(bufr_descriptor* v, long scale)
v->factor = codes_power<double>(-scale, 10);
}
int grib_bufr_descriptor_can_be_missing(bufr_descriptor* v)
int grib_bufr_descriptor_can_be_missing(const bufr_descriptor* v)
{
if (v->code == 31031 || v->code == 999999)
return 0;