diff --git a/src/expression/grib_arguments.cc b/src/expression/grib_arguments.cc index b448f7202..96a8030ec 100644 --- a/src/expression/grib_arguments.cc +++ b/src/expression/grib_arguments.cc @@ -53,7 +53,7 @@ void Arguments::print(grib_handle* f) const const char* Arguments::get_name(grib_handle* h, int n) const { - Expression* e = NULL; + const Expression* e = NULL; const Arguments* args = this; while (args && n-- > 0) { args = args->next_; @@ -68,7 +68,6 @@ const char* Arguments::get_name(grib_handle* h, int n) const const char* Arguments::get_string(grib_handle* h, int n) const { - Expression* e = NULL; const Arguments* args = this; int ret = 0; while (args && n-- > 0) { @@ -78,7 +77,7 @@ const char* Arguments::get_string(grib_handle* h, int n) const if (!args) return NULL; - e = args->expression_; + const Expression* e = args->expression_; return e->evaluate_string(h, NULL, NULL, &ret); } @@ -86,7 +85,6 @@ long Arguments::get_long(grib_handle* h, int n) const { int ret = 0; long lres = 0; - grib_expression* e = NULL; const Arguments* args = this; while (args && n-- > 0) { args = args->next_; @@ -95,7 +93,7 @@ long Arguments::get_long(grib_handle* h, int n) const if (!args) return 0; - e = args->expression_; + const grib_expression* e = args->expression_; ret = e->evaluate_long(h, &lres); (void)ret; return lres; @@ -106,7 +104,6 @@ double Arguments::get_double(grib_handle* h, int n) const int ret = 0; double dres = 0.0; - Expression* e = NULL; const Arguments* args = this; while (args && n-- > 0) { args = args->next_; @@ -115,7 +112,7 @@ double Arguments::get_double(grib_handle* h, int n) const if (!args) return 0; - e = args->expression_; + const Expression* e = args->expression_; ret = e->evaluate_double(h, &dres); (void)ret; return dres; diff --git a/src/expression/grib_expression_class_double.h b/src/expression/grib_expression_class_double.h index 9657b3c26..5df2cb258 100644 --- a/src/expression/grib_expression_class_double.h +++ b/src/expression/grib_expression_class_double.h @@ -19,7 +19,6 @@ class Double : public Expression public: Double(grib_context*, double); - void destroy(grib_context*) override {} void print(grib_context*, grib_handle*, FILE*) const override; void add_dependency(grib_accessor*) override {} int native_type(grib_handle*) const override; diff --git a/src/expression/grib_expression_class_functor.cc b/src/expression/grib_expression_class_functor.cc index e8e9cb174..901e357a5 100644 --- a/src/expression/grib_expression_class_functor.cc +++ b/src/expression/grib_expression_class_functor.cc @@ -45,11 +45,14 @@ int Functor::evaluate_long(grib_handle* h, long* lres) const } if (STR_EQUAL(name_, "abs")) { - grib_expression* exp = args_ ? args_->get_expression(h, 0) : nullptr; - long lval = 0; - int ret = exp->evaluate_long(h, &lval); - *lres = abs(lval); - return ret; + const grib_expression* exp = args_ ? args_->get_expression(h, 0) : nullptr; + if (exp) { + long lval = 0; + int ret = exp->evaluate_long(h, &lval); + *lres = abs(lval); + return ret; + } + return GRIB_INVALID_ARGUMENT; } if (STR_EQUAL(name_, "size")) { diff --git a/src/expression/grib_expression_class_long.cc b/src/expression/grib_expression_class_long.cc index 7b17a2595..97e667eb8 100644 --- a/src/expression/grib_expression_class_long.cc +++ b/src/expression/grib_expression_class_long.cc @@ -29,11 +29,6 @@ void Long::print(grib_context* c, grib_handle* f, FILE* out) const fprintf(out, "long(%ld)", value_); } -void Long::destroy(grib_context* c) -{ - /* grib_expression_long* e = (grib_expression_long*)g; */ -} - void Long::add_dependency(grib_accessor* observer) { /* grib_expression_long* e = (grib_expression_long*)g; */ diff --git a/src/expression/grib_expression_class_long.h b/src/expression/grib_expression_class_long.h index ed77362d1..f1a609b34 100644 --- a/src/expression/grib_expression_class_long.h +++ b/src/expression/grib_expression_class_long.h @@ -18,7 +18,6 @@ class Long : public Expression { public: Long(long value) : value_(value) {} - void destroy(grib_context*) override; void print(grib_context*, grib_handle*, FILE*) const override; void add_dependency(grib_accessor*) override; int native_type(grib_handle*) const override; diff --git a/src/expression/grib_expression_class_true.h b/src/expression/grib_expression_class_true.h index 7b2aab874..588dfa767 100644 --- a/src/expression/grib_expression_class_true.h +++ b/src/expression/grib_expression_class_true.h @@ -17,7 +17,7 @@ namespace eccodes::expression { class True : public Expression { public: True() = default; - void destroy(grib_context*) override {} + void print(grib_context*, grib_handle*, FILE*) const override; void add_dependency(grib_accessor*) override {}; int native_type(grib_handle*) const override;