From 141e2acc0d2cdc50a8f5915a023d86732fca2953 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 19 Feb 2024 22:08:24 +0000 Subject: [PATCH] Dead code removal --- src/eccodes_prototypes.h | 1 - src/grib_expression.cc | 75 ++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index b072d5191..3537fc05f 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1311,7 +1311,6 @@ const char* grib_expression_get_name(grib_expression* g); void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f); void grib_expression_free(grib_context* ctx, grib_expression* g); void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer); -int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v); grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n); void grib_arguments_free(grib_context* c, grib_arguments* g); void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f); diff --git a/src/grib_expression.cc b/src/grib_expression.cc index c3cd36305..4c1109640 100644 --- a/src/grib_expression.cc +++ b/src/grib_expression.cc @@ -19,8 +19,7 @@ int grib_expression_native_type(grib_handle* h, grib_expression* g) c = c->super ? *(c->super) : NULL; } if (g->cclass) - grib_context_log(h->context, GRIB_LOG_ERROR, "No native_type() in %s", g->cclass->name); - Assert(1 == 0); + grib_context_log(h->context, GRIB_LOG_FATAL, "%s: No native_type() in %s", __func__, g->cclass->name); return 0; } @@ -55,7 +54,7 @@ const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g, c = c->super ? *(c->super) : NULL; } if (g->cclass) - grib_context_log(h->context, GRIB_LOG_ERROR, "No evaluate_string() in %s", g->cclass->name); + grib_context_log(h->context, GRIB_LOG_ERROR, "%s: No evaluate_string() in %s", __func__, g->cclass->name); *err = GRIB_INVALID_TYPE; return 0; @@ -69,8 +68,9 @@ const char* grib_expression_get_name(grib_expression* g) return c->get_name(g); c = c->super ? *(c->super) : NULL; } - if (g->cclass) printf("No expression_get_name() in %s\n", g->cclass->name); - Assert(1 == 0); + if (g->cclass) { + grib_context_log(grib_context_get_default(), GRIB_LOG_FATAL, "%s: No get_name() in %s", __func__, g->cclass->name); + } return 0; } @@ -84,7 +84,6 @@ void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f } c = c->super ? *(c->super) : NULL; } - Assert(1 == 0); } void grib_expression_free(grib_context* ctx, grib_expression* g) @@ -110,43 +109,37 @@ void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer) } c = c->super ? *(c->super) : NULL; } - Assert(1 == 0); } -/*----------------------------------------*/ -int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v) -{ - char buffer[1024]; - int ret = 0; - size_t size = sizeof(buffer); - - switch (v->type = grib_expression_native_type(h, g)) { - case GRIB_TYPE_LONG: - return grib_expression_evaluate_long(h, g, &v->long_value); - break; - - case GRIB_TYPE_DOUBLE: - return grib_expression_evaluate_double(h, g, &v->double_value); - break; - - case GRIB_TYPE_STRING: - v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_ERROR, - "grib_expression_set_value: unable to evaluate %s as string", - grib_expression_get_name(g)); - return ret; - } - Assert(v->string_value != buffer); - Assert(v->string_value); - break; - - default: - Assert(1 == 0); - break; - } - return 0; -} +// int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v) +// { +// char buffer[1024]; +// int ret = 0; +// size_t size = sizeof(buffer); +// switch (v->type = grib_expression_native_type(h, g)) { +// case GRIB_TYPE_LONG: +// return grib_expression_evaluate_long(h, g, &v->long_value); +// break; +// case GRIB_TYPE_DOUBLE: +// return grib_expression_evaluate_double(h, g, &v->double_value); +// break; +// case GRIB_TYPE_STRING: +// v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret); +// if (ret != GRIB_SUCCESS) { +// grib_context_log(h->context, GRIB_LOG_ERROR, +// "grib_expression_set_value: unable to evaluate %s as string", +// grib_expression_get_name(g)); +// return ret; +// } +// Assert(v->string_value != buffer); +// Assert(v->string_value); +// break; +// default: +// Assert(!"grib_expression_set_value"); +// break; +// } +// return 0; +// } /*----------------------------------------*/ grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n)