Dead code removal

This commit is contained in:
shahramn 2024-08-19 14:38:12 +01:00
parent 0771826bdf
commit 2349dc3e7c
3 changed files with 12 additions and 29 deletions

View File

@ -264,22 +264,21 @@ static int test_bit(long a, long b)
static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
{ {
grib_dumper_debug* self = (grib_dumper_debug*)d; grib_dumper_debug* self = (grib_dumper_debug*)d;
long value = 0;
size_t size = 1;
int err = a->unpack_long(&value, &size);
int i;
if (a->length == 0 && if (a->length == 0 &&
(d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0)
return; return;
size_t size = 1;
long value = 0;
int err = a->unpack_long(&value, &size);
set_begin_end(d, a); set_begin_end(d, a);
for (i = 0; i < d->depth; i++) for (int i = 0; i < d->depth; i++)
fprintf(self->dumper.out, " "); fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "%ld-%ld %s %s = %ld [", self->begin, self->theEnd, a->creator->op, a->name, value); fprintf(self->dumper.out, "%ld-%ld %s %s = %ld [", self->begin, self->theEnd, a->creator->op, a->name, value);
for (i = 0; i < (a->length * 8); i++) { for (long i = 0; i < (a->length * 8); i++) {
if (test_bit(value, a->length * 8 - i - 1)) if (test_bit(value, a->length * 8 - i - 1))
fprintf(self->dumper.out, "1"); fprintf(self->dumper.out, "1");
else else

View File

@ -212,27 +212,14 @@ static int test_bit(long a, long b)
static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
{ {
grib_dumper_default* self = (grib_dumper_default*)d; grib_dumper_default* self = (grib_dumper_default*)d;
int i;
long lvalue = 0; long lvalue = 0;
double dvalue = 0;
size_t size = 1; size_t size = 1;
int err = 0; int err = 0;
int isDouble = 0;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return; return;
switch (a->get_native_type()) { err = a->unpack_long(&lvalue, &size);
case GRIB_TYPE_LONG:
a->unpack_long(&lvalue, &size);
break;
case GRIB_TYPE_DOUBLE:
a->unpack_double(&dvalue, &size);
isDouble = 1;
break;
default:
break;
}
print_offset(self->dumper.out, d, a); print_offset(self->dumper.out, d, a);
@ -249,7 +236,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out, " "); fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "# flags: "); fprintf(self->dumper.out, "# flags: ");
for (i = 0; i < (a->length * 8); i++) { for (long i = 0; i < (a->length * 8); i++) {
if (test_bit(lvalue, a->length * 8 - i - 1)) if (test_bit(lvalue, a->length * 8 - i - 1))
fprintf(self->dumper.out, "1"); fprintf(self->dumper.out, "1");
else else
@ -261,19 +248,16 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out, " "); fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "#-READ ONLY- "); fprintf(self->dumper.out, "#-READ ONLY- ");
} }
else else {
fprintf(self->dumper.out, " "); fprintf(self->dumper.out, " ");
}
if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal())
fprintf(self->dumper.out, "%s = MISSING;", a->name); fprintf(self->dumper.out, "%s = MISSING;", a->name);
else { else {
if (isDouble)
fprintf(self->dumper.out, "%s = %g;", a->name, dvalue);
else
fprintf(self->dumper.out, "%s = %ld;", a->name, lvalue); fprintf(self->dumper.out, "%s = %ld;", a->name, lvalue);
} }
if (err) { if (err) {
fprintf(self->dumper.out, " "); fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "# *** ERR=%d (%s) [grib_dumper_default::dump_bits]", err, grib_get_error_message(err)); fprintf(self->dumper.out, "# *** ERR=%d (%s) [grib_dumper_default::dump_bits]", err, grib_get_error_message(err));

View File

@ -219,7 +219,6 @@ static int test_bit(long a, long b)
static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
{ {
grib_dumper_wmo* self = (grib_dumper_wmo*)d; grib_dumper_wmo* self = (grib_dumper_wmo*)d;
int i;
long value = 0; long value = 0;
size_t size = 1; size_t size = 1;
int err = 0; int err = 0;
@ -237,7 +236,8 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment)
fprintf(self->dumper.out, "%s (int) ", a->creator->op); fprintf(self->dumper.out, "%s (int) ", a->creator->op);
fprintf(self->dumper.out, "%s = %ld [", a->name, value); fprintf(self->dumper.out, "%s = %ld [", a->name, value);
for (i = 0; i < (a->length * 8); i++) {
for (long i = 0; i < (a->length * 8); i++) {
if (test_bit(value, a->length * 8 - i - 1)) if (test_bit(value, a->length * 8 - i - 1))
fprintf(self->dumper.out, "1"); fprintf(self->dumper.out, "1");
else else