Skip to content

Commit 9ccb71f

Browse files
committed
Accessors: Check args in debug mode
1 parent 006c759 commit 9ccb71f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/accessor/grib_accessor_class_g2_param_concept_filename.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ void grib_accessor_g2_param_concept_filename_t::init(const long len, grib_argume
1818
grib_accessor_gen_t::init(len, arg);
1919
grib_handle* h = grib_handle_of_accessor(this);
2020

21-
const int numArgs = arg->get_count();
22-
if (numArgs != 3) {
23-
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 3",
24-
class_name_, name_, numArgs);
21+
if (context_->debug) {
22+
const int numArgs = arg->get_count();
23+
if (numArgs != 3) {
24+
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 3",
25+
class_name_, name_, numArgs);
26+
}
2527
}
2628

2729
basename_ = arg->get_string(h, 0);

src/accessor/grib_accessor_class_mtg2_switch_default.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ void grib_accessor_mtg2_switch_default_t::init(const long len, grib_arguments* a
1818
grib_accessor_long_t::init(len, arg);
1919

2020
grib_handle* h = grib_handle_of_accessor(this);
21-
const int numArgs = arg->get_count();
22-
if (numArgs != 4) {
23-
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 4",
24-
class_name_, name_, numArgs);
21+
22+
if (context_->debug) {
23+
const int numArgs = arg->get_count();
24+
if (numArgs != 4) {
25+
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 4",
26+
class_name_, name_, numArgs);
27+
}
2528
}
2629

2730
tablesVersion_ = arg->get_name(h, 0);

0 commit comments

Comments
 (0)