diff --git a/persistent-data/data-structures/btree_node_checker.cc b/persistent-data/data-structures/btree_node_checker.cc index a6c77e0..0f50670 100644 --- a/persistent-data/data-structures/btree_node_checker.cc +++ b/persistent-data/data-structures/btree_node_checker.cc @@ -6,11 +6,11 @@ using persistent_data::btree_detail::btree_node_checker; //---------------------------------------------------------------- -btree_node_checker::error_type btree_node_checker::get_last_error() { +btree_node_checker::error_type btree_node_checker::get_last_error() const { return last_error_; } -std::string btree_node_checker::get_last_error_string() { +std::string btree_node_checker::get_last_error_string() const { switch (last_error_) { case BLOCK_NR_MISMATCH: return block_nr_mismatch_string(); @@ -39,7 +39,7 @@ void btree_node_checker::reset() { last_error_ = NO_ERROR; } -std::string btree_node_checker::block_nr_mismatch_string() { +std::string btree_node_checker::block_nr_mismatch_string() const { std::ostringstream out; out << "block number mismatch: actually " << error_location_ @@ -48,7 +48,7 @@ std::string btree_node_checker::block_nr_mismatch_string() { return out.str(); } -std::string btree_node_checker::value_sizes_mismatch_string() { +std::string btree_node_checker::value_sizes_mismatch_string() const { std::ostringstream out; out << "value size mismatch: expected " << error_value_sizes_[1] << ", but got " << error_value_sizes_[0] @@ -58,7 +58,7 @@ std::string btree_node_checker::value_sizes_mismatch_string() { return out.str(); } -std::string btree_node_checker::max_entries_too_large_string() { +std::string btree_node_checker::max_entries_too_large_string() const { std::ostringstream out; out << "max entries too large: " << error_max_entries_ << " (block " << error_location_ << ")"; @@ -66,7 +66,7 @@ std::string btree_node_checker::max_entries_too_large_string() { return out.str(); } -std::string btree_node_checker::max_entries_not_divisible_string() { +std::string btree_node_checker::max_entries_not_divisible_string() const { std::ostringstream out; out << "max entries is not divisible by 3: " << error_max_entries_ << " (block " << error_location_ << ")"; @@ -74,7 +74,7 @@ std::string btree_node_checker::max_entries_not_divisible_string() { return out.str(); } -std::string btree_node_checker::nr_entries_too_large_string() { +std::string btree_node_checker::nr_entries_too_large_string() const { std::ostringstream out; out << "bad nr_entries: " << error_nr_entries_ << " < " @@ -84,7 +84,7 @@ std::string btree_node_checker::nr_entries_too_large_string() { return out.str(); } -std::string btree_node_checker::nr_entries_too_small_string() { +std::string btree_node_checker::nr_entries_too_small_string() const { std::ostringstream out; out << "too few entries in btree_node: " << error_nr_entries_ @@ -96,7 +96,7 @@ std::string btree_node_checker::nr_entries_too_small_string() { return out.str(); } -std::string btree_node_checker::keys_out_of_order_string() { +std::string btree_node_checker::keys_out_of_order_string() const { std::ostringstream out; out << "keys are out of order, " << error_keys_[0] << " <= " << error_keys_[1] @@ -105,7 +105,7 @@ std::string btree_node_checker::keys_out_of_order_string() { return out.str(); } -std::string btree_node_checker::parent_key_mismatch_string() { +std::string btree_node_checker::parent_key_mismatch_string() const { std::ostringstream out; out << "parent key mismatch: parent was " << error_keys_[1] << ", but lowest in node was " << error_keys_[0] @@ -114,7 +114,7 @@ std::string btree_node_checker::parent_key_mismatch_string() { return out.str(); } -std::string btree_node_checker::leaf_key_overlapped_string() { +std::string btree_node_checker::leaf_key_overlapped_string() const { std::ostringstream out; out << "the last key of the previous leaf was " << error_keys_[1] << " and the first key of this leaf is " << error_keys_[0] diff --git a/persistent-data/data-structures/btree_node_checker.h b/persistent-data/data-structures/btree_node_checker.h index 926f613..be50007 100644 --- a/persistent-data/data-structures/btree_node_checker.h +++ b/persistent-data/data-structures/btree_node_checker.h @@ -41,6 +41,8 @@ namespace persistent_data { error_keys_{0, 0} { } + virtual ~btree_node_checker() {} + template bool check_block_nr(btree_detail::node_ref const &n) { if (n.get_location() != n.get_block_nr()) { @@ -175,20 +177,20 @@ namespace persistent_data { return true; } - error_type get_last_error(); - std::string get_last_error_string(); + error_type get_last_error() const; + std::string get_last_error_string() const; void reset(); private: - std::string block_nr_mismatch_string(); - std::string value_sizes_mismatch_string(); - std::string max_entries_too_large_string(); - std::string max_entries_not_divisible_string(); - std::string nr_entries_too_large_string(); - std::string nr_entries_too_small_string(); - std::string keys_out_of_order_string(); - std::string parent_key_mismatch_string(); - std::string leaf_key_overlapped_string(); + std::string block_nr_mismatch_string() const; + std::string value_sizes_mismatch_string() const; + std::string max_entries_too_large_string() const; + std::string max_entries_not_divisible_string() const; + std::string nr_entries_too_large_string() const; + std::string nr_entries_too_small_string() const; + std::string keys_out_of_order_string() const; + std::string parent_key_mismatch_string() const; + std::string leaf_key_overlapped_string() const; error_type last_error_; block_address error_location_; diff --git a/thin-provisioning/thin_ll_dump.cc b/thin-provisioning/thin_ll_dump.cc index f16a745..94f6a08 100644 --- a/thin-provisioning/thin_ll_dump.cc +++ b/thin-provisioning/thin_ll_dump.cc @@ -330,7 +330,7 @@ thin_ll_dump_cmd::run(int argc, char **argv) boost::optional output; flags f; - char c; + int c; while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { switch(c) { case 'h': diff --git a/thin-provisioning/thin_ll_restore.cc b/thin-provisioning/thin_ll_restore.cc index 27ab184..4082e0b 100644 --- a/thin-provisioning/thin_ll_restore.cc +++ b/thin-provisioning/thin_ll_restore.cc @@ -87,7 +87,7 @@ namespace { device_tree_detail::device_details details; device_tree::ptr details_tree; - boost::optional details_root = get_opt_attr(attr, "blocknr"); + boost::optional details_root = get_opt_attr(attr, "blocknr"); if (details_root) details_tree = device_tree::ptr(new device_tree(*md->tm_, *details_root, device_tree_detail::device_details_traits::ref_counter())); @@ -112,7 +112,7 @@ namespace { } void parse_node(metadata::ptr md, emitter::ptr e, attributes const &attr) { - metadata_dump_subtree(md, e, true, get_attr(attr, "blocknr")); + metadata_dump_subtree(md, e, true, get_attr(attr, "blocknr")); } void start_tag(void *data, char const *el, char const **attr) { @@ -216,7 +216,7 @@ thin_ll_restore_cmd::run(int argc, char **argv) { string output; string input_metadata; flags f; - char c; + int c; const char shortopts[] = "hi:o:E:V"; const struct option longopts[] = { diff --git a/thin-provisioning/thin_scan.cc b/thin-provisioning/thin_scan.cc index 1ed7a6b..6f63df0 100644 --- a/thin-provisioning/thin_scan.cc +++ b/thin-provisioning/thin_scan.cc @@ -383,7 +383,7 @@ thin_scan_cmd::run(int argc, char **argv) boost::optional output; flags f; - char c; + int c; while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { switch(c) { case 'h':