From 16a10d2554d97f69aec25cee524f4babd734d5e5 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 28 May 2020 14:43:03 +0100 Subject: [PATCH] [thin_check] Remove the metadata_checker base class. It's really only a single method. --- thin-provisioning/metadata_checker.cc | 21 ++++++++++----------- thin-provisioning/metadata_checker.h | 17 ++++------------- thin-provisioning/thin_check.cc | 3 +-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/thin-provisioning/metadata_checker.cc b/thin-provisioning/metadata_checker.cc index 3e48f87..21383bb 100644 --- a/thin-provisioning/metadata_checker.cc +++ b/thin-provisioning/metadata_checker.cc @@ -289,11 +289,11 @@ namespace { //-------------------------------- - class base_metadata_checker : public metadata_checker { + class metadata_checker { public: - base_metadata_checker(block_manager::ptr bm, - check_options check_opts, - output_options output_opts) + metadata_checker(block_manager::ptr bm, + check_options check_opts, + output_options output_opts) : bm_(bm), options_(check_opts), out_(cerr, 2), @@ -412,14 +412,13 @@ void check_options::set_override_mapping_root(block_address b) { override_mapping_root_ = b; } -metadata_checker::ptr -thin_provisioning::create_base_checker(block_manager::ptr bm, - check_options const &check_opts, - output_options output_opts) +base::error_state +thin_provisioning::check_metadata(block_manager::ptr bm, + check_options const &check_opts, + output_options output_opts) { - metadata_checker::ptr checker; - checker = metadata_checker::ptr(new base_metadata_checker(bm, check_opts, output_opts)); - return checker; + metadata_checker checker(bm, check_opts, output_opts); + return checker.check(); } //---------------------------------------------------------------- diff --git a/thin-provisioning/metadata_checker.h b/thin-provisioning/metadata_checker.h index 8f058fc..6f25587 100644 --- a/thin-provisioning/metadata_checker.h +++ b/thin-provisioning/metadata_checker.h @@ -56,19 +56,10 @@ namespace thin_provisioning { OUTPUT_QUIET, }; - class metadata_checker { - public: - typedef std::shared_ptr ptr; - - virtual ~metadata_checker() {} - - virtual base::error_state check() = 0; - }; - - metadata_checker::ptr - create_base_checker(persistent_data::block_manager::ptr bm, - check_options const &check_opts, - output_options output_opts); + base::error_state + check_metadata(persistent_data::block_manager::ptr bm, + check_options const &check_opts, + output_options output_opts); } //---------------------------------------------------------------- diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index 79ea171..6b65395 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -78,8 +78,7 @@ namespace { block_manager::ptr bm = open_bm(path); output_options output_opts = !fs.quiet ? OUTPUT_NORMAL : OUTPUT_QUIET; - metadata_checker::ptr checker = create_base_checker(bm, fs.check_opts, output_opts); - error_state err = checker->check(); + error_state err = check_metadata(bm, fs.check_opts, output_opts); if (fs.ignore_non_fatal_errors) success = (err == FATAL) ? false : true;