diff --git a/src/grib_dumper_class_debug.cc b/src/grib_dumper_class_debug.cc index ead1c7cf4..d740e4523 100644 --- a/src/grib_dumper_class_debug.cc +++ b/src/grib_dumper_class_debug.cc @@ -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) { 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 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; + size_t size = 1; + long value = 0; + int err = a->unpack_long(&value, &size); 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, "%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)) fprintf(self->dumper.out, "1"); else diff --git a/src/grib_dumper_class_default.cc b/src/grib_dumper_class_default.cc index 5e093186b..ab7d9fe75 100644 --- a/src/grib_dumper_class_default.cc +++ b/src/grib_dumper_class_default.cc @@ -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) { grib_dumper_default* self = (grib_dumper_default*)d; - int i; long lvalue = 0; - double dvalue = 0; size_t size = 1; int err = 0; - int isDouble = 0; if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - switch (a->get_native_type()) { - case GRIB_TYPE_LONG: - a->unpack_long(&lvalue, &size); - break; - case GRIB_TYPE_DOUBLE: - a->unpack_double(&dvalue, &size); - isDouble = 1; - break; - default: - break; - } + err = a->unpack_long(&lvalue, &size); 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, "# 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)) fprintf(self->dumper.out, "1"); 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, "#-READ ONLY- "); } - else + else { fprintf(self->dumper.out, " "); + } if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); 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) { fprintf(self->dumper.out, " "); fprintf(self->dumper.out, "# *** ERR=%d (%s) [grib_dumper_default::dump_bits]", err, grib_get_error_message(err)); diff --git a/src/grib_dumper_class_wmo.cc b/src/grib_dumper_class_wmo.cc index 3949e97a2..77c8b1ccd 100644 --- a/src/grib_dumper_class_wmo.cc +++ b/src/grib_dumper_class_wmo.cc @@ -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) { grib_dumper_wmo* self = (grib_dumper_wmo*)d; - int i; long value = 0; size_t size = 1; 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 = %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)) fprintf(self->dumper.out, "1"); else