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*/ /* 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_new(grib_accessor* tables_accessor, int code, int silent, int* err);
bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d); 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); 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); void grib_bufr_descriptor_delete(bufr_descriptor* v);
/* grib_bufr_descriptors_array.cc*/ /* 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; *err = GRIB_DECODING_ERROR;
return; return;
} }
grib_bufr_descriptor_set_code(0, (size - 1) * 1000 + 100000, uidx); grib_bufr_descriptor_set_code(uidx, (size - 1) * 1000 + 100000);
size++; size++;
} }
else { else {
@ -602,7 +602,7 @@ static int expand(grib_accessor* a)
bufr_descriptors_array* unexpanded_copy = NULL; bufr_descriptors_array* unexpanded_copy = NULL;
bufr_descriptors_array* expanded = NULL; bufr_descriptors_array* expanded = NULL;
grib_context* c = a->context; 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 */ int operator206yyy_width = 0; /* width specified by operator 206YYY */
if (!self->do_expand) { 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,}; char buf[25] = {0,};
long llen = 0; long llen = 0;
size_t i = 0, size = 0; size_t i = 0, size = 0;
grib_context* c = a->context; const grib_context* c = a->context;
err = grib_value_count(a, &llen); err = grib_value_count(a, &llen);
if (err) return err; if (err) return err;

View File

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