From 4d57fc79fd4f761ade2f434e451f4b6737c0badd Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 20 Oct 2023 20:14:32 +0100 Subject: [PATCH] Dead code removal --- src/action.cc | 43 ++++++++++++++-------------- src/action_class_alias.cc | 22 ++------------ src/action_class_gen.cc | 10 ++----- src/action_class_if.cc | 8 ++---- src/action_class_modify.cc | 8 ++---- src/action_class_noop.cc | 9 ++---- src/action_class_remove.cc | 8 ++---- src/action_class_rename.cc | 9 ++---- src/action_class_section.cc | 19 ++---------- src/action_class_set.cc | 12 ++------ src/action_class_set_darray.cc | 9 ++---- src/action_class_set_sarray.cc | 12 ++------ src/action_class_switch.cc | 12 ++------ src/action_class_transient_darray.cc | 13 ++------- src/action_class_when.cc | 9 ++---- src/eccodes_prototypes.h | 2 -- 16 files changed, 50 insertions(+), 155 deletions(-) diff --git a/src/action.cc b/src/action.cc index 847862edc..026bca74e 100644 --- a/src/action.cc +++ b/src/action.cc @@ -98,22 +98,21 @@ static void grib_dump(grib_action* a, FILE* f, int l) DEBUG_ASSERT(0); } -void grib_xref(grib_action* a, FILE* f, const char* path) -{ - grib_action_class* c = a->cclass; - init(c); - - while (c) { - if (c->xref) { - c->xref(a, f, path); - return; - } - c = c->super ? *(c->super) : NULL; - } - printf("xref not implemented for %s\n", a->cclass->name); - DEBUG_ASSERT(0); -} +// void grib_xref(grib_action* a, FILE* f, const char* path) +// { +// grib_action_class* c = a->cclass; +// init(c); +// while (c) { +// if (c->xref) { +// c->xref(a, f, path); +// return; +// } +// c = c->super ? *(c->super) : NULL; +// } +// printf("xref not implemented for %s\n", a->cclass->name); +// DEBUG_ASSERT(0); +// } void grib_action_delete(grib_context* context, grib_action* a) { @@ -214,10 +213,10 @@ void grib_dump_action_tree(grib_context* ctx, FILE* out) grib_dump_action_branch(out, ctx->grib_reader->first->root, 0); } -void grib_xref_action_branch(FILE* out, grib_action* a, const char* path) -{ - while (a) { - grib_xref(a, out, path); - a = a->next; - } -} +// void grib_xref_action_branch(FILE* out, grib_action* a, const char* path) +// { +// while (a) { +// grib_xref(a, out, path); +// a = a->next; +// } +// } diff --git a/src/action_class_alias.cc b/src/action_class_alias.cc index 945d3aa7a..014a3f47c 100644 --- a/src/action_class_alias.cc +++ b/src/action_class_alias.cc @@ -19,7 +19,7 @@ START_CLASS_DEF CLASS = action IMPLEMENTS = create_accessor - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy MEMBERS = char* target END_CLASS_DEF @@ -38,7 +38,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); @@ -60,7 +59,7 @@ static grib_action_class _grib_action_class_alias = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -268,23 +267,6 @@ static void dump(grib_action* act, FILE* f, int lvl) grib_context_print(act->context, f, " unalias %s \n", act->name); } -static void xref(grib_action* act, FILE* f, const char* path) -{ - Assert(!"xref is disabled"); - - // grib_action_alias* a = (grib_action_alias*)act; - // if (a->target) { - // fprintf(f, "bless({name=>'%s', target=>'%s', path=>'%s'},'xref::alias'),\n", act->name, a->target, path); - // if (act->name_space) - // fprintf(f, "bless({name=>'%s.%s', target=>'%s', path=>'%s'},'xref::alias'),\n", act->name_space, act->name, a->target, path); - // } - // else { - // fprintf(f, "bless({name=>'%s', path=>'%s'},'xref::unalias'),\n", act->name, path); - // if (act->name_space) - // fprintf(f, "bless({name=>'%s.%s', path=>'%s'},'xref::unalias'),\n", act->name_space, act->name, path); - // } -} - static void destroy(grib_context* context, grib_action* act) { grib_action_alias* a = (grib_action_alias*)act; diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index 8c5945889..641aa3c92 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -19,7 +19,7 @@ START_CLASS_DEF CLASS = action IMPLEMENTS = create_accessor - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy IMPLEMENTS = notify_change MEMBERS = long len @@ -40,7 +40,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed); @@ -64,7 +63,7 @@ static grib_action_class _grib_action_class_gen = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -130,11 +129,6 @@ static void dump(grib_action* act, FILE* f, int lvl) // For xref implementation see // src/deprecated/action_class_gen.cc -static void xref(grib_action* act, FILE* f, const char* path) -{ - Assert(!"xref is disabled"); -} - static int create_accessor(grib_section* p, grib_action* act, grib_loader* loader) { grib_action_gen* a = (grib_action_gen*)act; diff --git a/src/action_class_if.cc b/src/action_class_if.cc index 4c94549af..a5d28725a 100644 --- a/src/action_class_if.cc +++ b/src/action_class_if.cc @@ -22,7 +22,6 @@ IMPLEMENTS = create_accessor IMPLEMENTS = dump IMPLEMENTS = destroy - IMPLEMENTS = xref IMPLEMENTS = reparse;execute MEMBERS = grib_expression *expression MEMBERS = grib_action *block_true @@ -44,7 +43,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit); @@ -73,7 +71,7 @@ static grib_action_class _grib_action_class_if = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -86,6 +84,7 @@ grib_action_class* grib_action_class_if = &_grib_action_class_if; static void init_class(grib_action_class* c) { + c->xref = (*(c->super))->xref; c->notify_change = (*(c->super))->notify_change; } /* END_CLASS_IMP */ @@ -306,6 +305,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->op); } -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_modify.cc b/src/action_class_modify.cc index c379d7300..ef09a3c96 100644 --- a/src/action_class_modify.cc +++ b/src/action_class_modify.cc @@ -17,7 +17,7 @@ START_CLASS_DEF CLASS = action - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = create_accessor IMPLEMENTS = destroy MEMBERS = long flags @@ -38,7 +38,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); @@ -61,7 +60,7 @@ static grib_action_class _grib_action_class_modify = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -128,6 +127,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->op); } -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_noop.cc b/src/action_class_noop.cc index c2b3bc2f0..d4d2ff133 100644 --- a/src/action_class_noop.cc +++ b/src/action_class_noop.cc @@ -17,7 +17,7 @@ START_CLASS_DEF CLASS = action - IMPLEMENTS = dump;destroy;xref;execute + IMPLEMENTS = dump;destroy;execute END_CLASS_DEF */ @@ -34,7 +34,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -55,7 +54,7 @@ static grib_action_class _grib_action_class_noop = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -101,10 +100,6 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->op); } -static void xref(grib_action* d, FILE* f, const char* path) -{ -} - static int execute(grib_action* act, grib_handle* h) { return 0; diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index 853a1a648..26ab6760b 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -19,7 +19,7 @@ CLASS = action IMPLEMENTS = create_accessor IMPLEMENTS = dump - IMPLEMENTS = destroy; xref + IMPLEMENTS = destroy MEMBERS = grib_arguments* args END_CLASS_DEF @@ -37,7 +37,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); @@ -59,7 +58,7 @@ static grib_action_class _grib_action_class_remove = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -153,6 +152,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->op); } -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_rename.cc b/src/action_class_rename.cc index 2666c4f75..b6533895e 100644 --- a/src/action_class_rename.cc +++ b/src/action_class_rename.cc @@ -19,7 +19,7 @@ CLASS = action IMPLEMENTS = create_accessor IMPLEMENTS = dump - IMPLEMENTS = destroy; xref + IMPLEMENTS = destroy MEMBERS = char* the_old MEMBERS = char* the_new END_CLASS_DEF @@ -38,7 +38,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); @@ -61,7 +60,7 @@ static grib_action_class _grib_action_class_rename = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -148,7 +147,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_section.cc b/src/action_class_section.cc index 6f9cd5836..9dda3dc30 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -19,8 +19,6 @@ START_CLASS_DEF CLASS = action IMPLEMENTS = notify_change - IMPLEMENTS = reparse - IMPLEMENTS = xref END_CLASS_DEF */ @@ -36,9 +34,7 @@ or edit "action.class" and rerun ./make_class.pl */ static void init_class (grib_action_class*); -static void xref (grib_action* d, FILE* f,const char* path); static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed); -static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit); typedef struct grib_action_section { @@ -57,12 +53,12 @@ static grib_action_class _grib_action_class_section = { 0, /* destroy */ 0, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ ¬ify_change, /* notify_change */ - &reparse, /* reparse */ + 0, /* reparse */ 0, /* execute */ }; @@ -231,14 +227,3 @@ static int notify_change(grib_action* act, grib_accessor* notified, return GRIB_SUCCESS; } - -static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit) -{ - fprintf(stderr, "action_class_section::reparse should be inherited: %s\n", a->name); - Assert(0); - return 0; -} - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_set.cc b/src/action_class_set.cc index 8febce99d..1068181d5 100644 --- a/src/action_class_set.cc +++ b/src/action_class_set.cc @@ -8,16 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Enrico Fucile * - ***************************************************************************/ #include "grib_api_internal.h" /* This is used by make_class.pl START_CLASS_DEF CLASS = action - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy;execute MEMBERS = grib_expression *expression MEMBERS = char *name @@ -38,7 +35,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -62,7 +58,7 @@ static grib_action_class _grib_action_class_set = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -135,7 +131,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_set_darray.cc b/src/action_class_set_darray.cc index 43d249594..97211a219 100644 --- a/src/action_class_set_darray.cc +++ b/src/action_class_set_darray.cc @@ -14,7 +14,7 @@ START_CLASS_DEF CLASS = action - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy;execute MEMBERS = grib_darray *darray MEMBERS = char *name @@ -34,7 +34,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -57,7 +56,7 @@ static grib_action_class _grib_action_class_set_darray = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -123,7 +122,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_set_sarray.cc b/src/action_class_set_sarray.cc index b12443f23..3b670aa87 100644 --- a/src/action_class_set_sarray.cc +++ b/src/action_class_set_sarray.cc @@ -8,16 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Enrico Fucile * - ***************************************************************************/ #include "grib_api_internal.h" /* This is used by make_class.pl START_CLASS_DEF CLASS = action - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy;execute MEMBERS = grib_sarray *sarray MEMBERS = char *name @@ -37,7 +34,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -60,7 +56,7 @@ static grib_action_class _grib_action_class_set_sarray = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -127,7 +123,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_switch.cc b/src/action_class_switch.cc index 57e47dc89..b116aa846 100644 --- a/src/action_class_switch.cc +++ b/src/action_class_switch.cc @@ -8,9 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Enrico Fucile * - ***************************************************************************/ #include "grib_api_internal.h" /* This is used by make_class.pl @@ -19,7 +16,6 @@ CLASS = action SUPER = action_class_section IMPLEMENTS = destroy - IMPLEMENTS = xref IMPLEMENTS = execute MEMBERS = grib_arguments* args MEMBERS = grib_case *Case @@ -39,7 +35,6 @@ or edit "action.class" and rerun ./make_class.pl */ static void init_class (grib_action_class*); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -65,7 +60,7 @@ static grib_action_class _grib_action_class_switch = { &destroy, /* destroy */ 0, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -79,6 +74,7 @@ grib_action_class* grib_action_class_switch = &_grib_action_class_switch; static void init_class(grib_action_class* c) { c->dump = (*(c->super))->dump; + c->xref = (*(c->super))->xref; c->create_accessor = (*(c->super))->create_accessor; c->notify_change = (*(c->super))->notify_change; c->reparse = (*(c->super))->reparse; @@ -240,7 +236,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_transient_darray.cc b/src/action_class_transient_darray.cc index ce4e514f9..9990beb41 100644 --- a/src/action_class_transient_darray.cc +++ b/src/action_class_transient_darray.cc @@ -8,9 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Enrico Fucile * - ***************************************************************************/ #include "grib_api_internal.h" /* This is used by make_class.pl @@ -18,7 +15,7 @@ START_CLASS_DEF CLASS = action SUPER = action_class_gen - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy;execute MEMBERS = grib_darray *darray MEMBERS = char *name @@ -38,7 +35,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int execute(grib_action* a,grib_handle* h); @@ -65,7 +61,7 @@ static grib_action_class _grib_action_class_transient_darray = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ 0, /* create_accessor*/ @@ -78,6 +74,7 @@ grib_action_class* grib_action_class_transient_darray = &_grib_action_class_tran static void init_class(grib_action_class* c) { + c->xref = (*(c->super))->xref; c->create_accessor = (*(c->super))->create_accessor; c->notify_change = (*(c->super))->notify_change; c->reparse = (*(c->super))->reparse; @@ -140,7 +137,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, a->name); grib_darray_delete(context, a->darray); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/action_class_when.cc b/src/action_class_when.cc index a274a7c27..49fc325be 100644 --- a/src/action_class_when.cc +++ b/src/action_class_when.cc @@ -18,7 +18,7 @@ START_CLASS_DEF CLASS = action IMPLEMENTS = create_accessor - IMPLEMENTS = dump;xref + IMPLEMENTS = dump IMPLEMENTS = destroy;notify_change MEMBERS = grib_expression *expression MEMBERS = grib_action *block_true @@ -40,7 +40,6 @@ or edit "action.class" and rerun ./make_class.pl static void init_class (grib_action_class*); static void dump (grib_action* d, FILE*,int); -static void xref (grib_action* d, FILE* f,const char* path); static void destroy (grib_context*,grib_action*); static int create_accessor(grib_section*,grib_action*,grib_loader*); static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed); @@ -66,7 +65,7 @@ static grib_action_class _grib_action_class_when = { &destroy, /* destroy */ &dump, /* dump */ - &xref, /* xref */ + 0, /* xref */ &create_accessor, /* create_accessor*/ @@ -232,7 +231,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - -static void xref(grib_action* d, FILE* f, const char* path) -{ -} diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index cf0985e86..ecdd83633 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -5,7 +5,6 @@ #endif /* action.cc */ -void grib_xref(grib_action* a, FILE* f, const char* path); void grib_action_delete(grib_context* context, grib_action* a); int grib_create_accessor(grib_section* p, grib_action* a, grib_loader* h); int grib_action_notify_change(grib_action* a, grib_accessor* observer, grib_accessor* observed); @@ -13,7 +12,6 @@ grib_action* grib_action_reparse(grib_action* a, grib_accessor* acc, int* doit); int grib_action_execute(grib_action* a, grib_handle* h); void grib_dump_action_branch(FILE* out, grib_action* a, int decay); void grib_dump_action_tree(grib_context* ctx, FILE* out); -void grib_xref_action_branch(FILE* out, grib_action* a, const char* path); /* action_class_alias.cc */ grib_action* grib_action_create_alias(grib_context* context, const char* name, const char* arg1, const char* name_space, int flags);