Dead code removal

This commit is contained in:
Shahram Najm 2023-06-28 10:35:39 +01:00
parent 7e0c771748
commit 30ebf99535
12 changed files with 28 additions and 120 deletions

View File

@ -613,11 +613,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len)
strcpy(tmp, table->entries[value].abbreviation);
}
else {
#if 1
snprintf(tmp, sizeof(tmp), "%d", (int)value);
#else
return GRIB_DECODING_ERROR;
#endif
}
l = strlen(tmp) + 1;

View File

@ -157,11 +157,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len)
strcpy(tmp, table->entries[value].title);
}
else {
#if 1
snprintf(tmp, sizeof(tmp), "%d", (int)value);
#else
return GRIB_DECODING_ERROR;
#endif
}
l = strlen(tmp) + 1;

View File

@ -210,17 +210,17 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
if (ret == GRIB_SUCCESS) {
n = a->offset + 4 * ((sub_k + 1) * (sub_k + 2));
#if 1
/* Octet number starts from beginning of message but shouldn't */
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n)) != GRIB_SUCCESS)
return ret;
#else
ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection);
if (ret != GRIB_SUCCESS)
return ret;
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS)
return ret;
#endif
// ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection);
// if (ret != GRIB_SUCCESS)
// return ret;
// if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS)
// return ret;
ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value);
if (ret != GRIB_SUCCESS)
return ret;

View File

@ -1252,7 +1252,6 @@ struct grib_int_array
int* el;
};
#if 1
struct grib_fieldset
{
grib_context* context;
@ -1267,7 +1266,6 @@ struct grib_fieldset
long current;
grib_field** fields;
};
#endif
/* concept index structures */

View File

@ -1069,17 +1069,15 @@ void grib_context_log(const grib_context* c, int level, const char* fmt, ...)
level = level & ~GRIB_LOG_PERROR;
/* #if HAS_STRERROR */
#if 1
strcat(msg, " (");
strcat(msg, strerror(errsv));
strcat(msg, ")");
#else
if (errsv > 0 && errsv < sys_nerr) {
strcat(msg, " (");
strcat(msg, sys_errlist[errsv]);
strcat(msg, " )");
}
#endif
// if (errsv > 0 && errsv < sys_nerr) {
// strcat(msg, " (");
// strcat(msg, sys_errlist[errsv]);
// strcat(msg, " )");
// }
}
if (c->output_log)

View File

@ -45,21 +45,19 @@ int grib_julian_to_datetime(double jd, long* year, long* month, long* day,
*day = (long)dday;
dday -= *day;
#if 1
/* ANF-CG 02.03.2012 */
s = ROUND((double)(dday * 86400)); /* total in sec , no msec*/
*hour = (long)s / 3600;
*minute = (long)((s % 3600) / 60);
*second = (long)(s % 60);
#else
/* Old algorithm, now replaced by above. See GRIB-180 */
dhour = dday * 24;
*hour = (long)dhour;
dhour -= *hour;
dminute = dhour * 60;
*minute = (long)dminute;
*second = (long)((dminute - *minute) * 60);
#endif
// Old algorithm, now replaced by above. See GRIB-180
// dhour = dday * 24;
// *hour = (long)dhour;
// dhour -= *hour;
// dminute = dhour * 60;
// *minute = (long)dminute;
// *second = (long)((dminute - *minute) * 60);
if (e < 14)
*month = e - 1;

View File

@ -453,7 +453,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
k = 0;
while (k < size) {
#if 1
int j;
for (i = 0; i < d->depth + 3; i++)
fprintf(self->dumper.out, " ");
@ -463,11 +462,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
fprintf(self->dumper.out, ", ");
}
fprintf(self->dumper.out, "\n");
#else
fprintf(self->dumper.out, "%d %g\n", k, buf[k]);
#endif
}
if (more) {
for (i = 0; i < d->depth + 3; i++)
@ -497,12 +491,11 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso
/* grib_section* s = grib_get_sub_section(a); */
grib_section* s = a->sub_section;
#if 1
if (a->name[0] == '_') {
grib_dump_accessors_block(d, block);
return;
}
#endif
for (i = 0; i < d->depth; i++)
fprintf(self->dumper.out, " ");
fprintf(self->dumper.out, "======> %s %s (%ld,%ld,%ld)\n", a->creator->op,

View File

@ -611,7 +611,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
k = 0;
while (k < size) {
#if 1
int j;
fprintf(self->dumper.out, " ");
for (j = 0; j < 5 && k < size; j++, k++) {
@ -620,11 +619,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
fprintf(self->dumper.out, ", ");
}
fprintf(self->dumper.out, "\n");
#else
fprintf(self->dumper.out, "%d %g\n", k, buf[k]);
#endif
}
if (more) {
fprintf(self->dumper.out, " ");

View File

@ -135,10 +135,8 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY))
return;
#if 1
if (comment)
pcomment(self->dumper.out, value, comment);
#endif
if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && (value == GRIB_MISSING_LONG))
fprintf(self->dumper.out, " GRIB_CHECK(grib_set_missing(h,\"%s\"),%d);\n", a->name, 0);
@ -231,10 +229,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
if (a->length == 0)
return;
#if 1
if (comment)
fprintf(self->dumper.out, "/* %s */\n", comment);
#endif
fprintf(self->dumper.out, " p = \"%s\";\n", value);
fprintf(self->dumper.out, " size = strlen(p);\n");

View File

@ -486,7 +486,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
k = 0;
while (k < size) {
#if 1
int j;
/*for(i = 0; i < d->depth + 3 ; i++) fprintf(self->dumper.out," ");*/
for (j = 0; j < 8 && k < size; j++, k++) {
@ -498,14 +497,10 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
fprintf(self->dumper.out, ", ");
}
fprintf(self->dumper.out, "\n");
#else
if (is_char)
fprintf(self->dumper.out, "%d '%c'\n", k, (char)buf[k]);
else
fprintf(self->dumper.out, "%d %g\n", k, buf[k]);
#endif
// if (is_char)
// fprintf(self->dumper.out, "%d '%c'\n", k, (char)buf[k]);
// else
// fprintf(self->dumper.out, "%d %g\n", k, buf[k]);
}
if (more) {
/*for(i = 0; i < d->depth + 3 ; i++) fprintf(self->dumper.out," ");*/

View File

@ -51,13 +51,9 @@ int grib_lookup_long_from_handle(grib_context* gc, grib_loader* loader, const ch
if (b)
return grib_unpack_long(b, value, &len);
/* TODO: fix me. For now, we don't fail on a lookup. */
#if 1
/* TODO: fix me. For now, we don't fail on a lookup. */
*value = -1;
return GRIB_SUCCESS;
#else
return GRIB_NOT_FOUND;
#endif
}
int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_arguments* default_value)

View File

@ -154,58 +154,6 @@ static void grib_md5_flush(grib_md5_state* s)
I_(c, d, a, b, 2, 62);
I_(b, c, d, a, 9, 63);
#else
unsigned long i, g;
unsigned long a = s->h0;
unsigned long b = s->h1;
unsigned long c = s->h2;
unsigned long d = s->h3;
unsigned long f;
unsigned long temp;
unsigned long* w = &s->words[0];
unsigned long h;
for (i = 0; i < 16; i++) {
f = F(b, c, d);
g = i;
temp = d;
d = c;
c = b;
h = a + f + k[i] + w[g];
b = b + rotate(h, r[i]);
a = temp;
}
for (i = 16; i < 32; i++) {
f = G(b, c, d);
g = (5 * i + 1) % 16;
temp = d;
d = c;
c = b;
h = a + f + k[i] + w[g];
b = b + rotate(h, r[i]);
a = temp;
}
for (i = 32; i < 48; i++) {
f = H(b, c, d);
g = (3 * i + 5) % 16;
temp = d;
d = c;
c = b;
h = a + f + k[i] + w[g];
b = b + rotate(h, r[i]);
a = temp;
}
for (i = 48; i < 64; i++) {
f = I(b, c, d);
g = (7 * i) % 16;
temp = d;
d = c;
c = b;
h = a + f + k[i] + w[g];
b = b + rotate(h, r[i]);
a = temp;
}
#endif
s->h0 += a;