From 1458690dcf85f2bdabfcfcdd6cf4ae7e1e7dd68a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sat, 6 Jan 2024 21:35:38 +0000 Subject: [PATCH] Tools: Dead code removal --- tools/gts_compare.cc | 2 +- tools/metar_compare.cc | 51 +----------------------------------------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index 2d3392526..b7692f65a 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -383,7 +383,7 @@ static void save_error(grib_context* c, const char* key) } } -static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type) +static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type) { size_t len1 = 0; size_t len2 = 0; diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index c8e824387..48db23534 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -452,7 +452,7 @@ static void save_error(grib_context* c, const char* key) } } -static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type) +static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type) { size_t len1 = 0; size_t len2 = 0; @@ -464,7 +464,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h int isMissing1 = 0, isMissing2 = 0; char *sval1 = NULL, *sval2 = NULL; - unsigned char *uval1 = NULL, *uval2 = NULL; double *dval1 = NULL, *dval2 = NULL; long *lval1 = NULL, *lval2 = NULL; double maxdiff = 0; @@ -760,54 +759,6 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h printf(" as bytes\n"); if (options->mode == MODE_METAR) return 0; - if (len1 < 2) - len1 = 512; - if (len2 < 2) - len2 = 512; - uval1 = (unsigned char*)grib_context_malloc(h1->context, len1 * sizeof(unsigned char)); - uval2 = (unsigned char*)grib_context_malloc(h2->context, len2 * sizeof(unsigned char)); - - if ((err1 = grib_get_bytes(h1, name, uval1, &len1)) != GRIB_SUCCESS) { - printInfo(h1); - save_error(c, name); - printf("Error: cannot get bytes value of [%s] in 1st field: %s\n", - name, grib_get_error_message(err1)); - } - - if ((err2 = grib_get_bytes(h2, name, uval2, &len2)) != GRIB_SUCCESS) { - printInfo(h1); - save_error(c, name); - printf("Error: cannot get bytes value of [%s] in 2nd field: %s\n", - name, grib_get_error_message(err2)); - } - - if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS) { - if (memcmp(uval1, uval2, len1) != 0) { - for (i = 0; i < len1; i++) - if (uval1[i] != uval2[i]) { - printInfo(h1); - save_error(c, name); - if (len1 == 1) - printf("[%s] byte values are different: [%02x] and [%02x]\n", - name, uval1[i], uval2[i]); - else - printf("[%s] byte value %d of %ld are different: [%02x] and [%02x]\n", - name, i, (long)len1, uval1[i], uval2[i]); - - err1 = GRIB_VALUE_MISMATCH; - break; - } - err1 = GRIB_VALUE_MISMATCH; - } - } - - grib_context_free(h1->context, uval1); - grib_context_free(h2->context, uval2); - - if (err1) - return err1; - if (err2) - return err2; break; case GRIB_TYPE_LABEL: