From 8147d798bea8718a26eca7305faefe686ed307d2 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Mon, 9 May 2016 13:25:26 +0300 Subject: [PATCH 1/4] don't use implicit rule when statically compiling emitters --- Makefile.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.in b/Makefile.in index fed1756..0b309c8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -129,10 +129,10 @@ CXX:=@CXX@ STRIP:=@STRIP@ OBJECTS:=$(subst .cc,.o,$(SOURCE)) -# FIXME OBJECTS += $(PLUGIN_LIBS) doesn't work, probably because it's empty at +# FIXME EMITTERS += $(PLUGIN_LIBS) doesn't work, probably because it's empty at # the time of use? ifeq ("@STATIC@", "yes") -OBJECTS += contrib/*.a +EMITTERS += contrib/*.a endif TOP_DIR:=@top_srcdir@ @@ -198,11 +198,11 @@ endif #---------------------------------------------------------------- -lib/libpdata.a: $(OBJECTS) +lib/libpdata.a: $(OBJECTS) $(EMITTERS) @echo " [AR] $<" - $(V)ar -rv $@ $(OBJECTS) > /dev/null 2>&1 + $(V)ar -rv $@ $(OBJECTS) $(EMITTERS) > /dev/null 2>&1 -bin/pdata_tools: $(OBJECTS) +bin/pdata_tools: $(OBJECTS) $(EMITTERS) @echo " [LD] $@" $(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(CXXLIB) From 2203e2b513430f66debf617bdb8e97a768ac6db4 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Wed, 18 May 2016 01:21:37 +0800 Subject: [PATCH 2/4] [btree_node_checker] tidy up the code 1. Add const qualifiers 2. Add virtual destructor --- .../data-structures/btree_node_checker.cc | 22 ++++++++--------- .../data-structures/btree_node_checker.h | 24 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) 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_; From 55ecf87439ef290931d0db87dfc70ce01e37d88e Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Wed, 18 May 2016 01:23:26 +0800 Subject: [PATCH 3/4] [thin_ll_restore] fix the data type of blocknr to uint64_t --- thin-provisioning/thin_ll_restore.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thin-provisioning/thin_ll_restore.cc b/thin-provisioning/thin_ll_restore.cc index 27ab184..ee1d88f 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) { From e985b8b3be62e4cfda7f29c611c36a08a938d0e1 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Thu, 19 May 2016 00:47:54 +0800 Subject: [PATCH 4/4] [thin_scan][thin_ll_*] fix the data type for getopt_long return value to int For toolchains represent char as unsigned type --- thin-provisioning/thin_ll_dump.cc | 2 +- thin-provisioning/thin_ll_restore.cc | 2 +- thin-provisioning/thin_scan.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 ee1d88f..4082e0b 100644 --- a/thin-provisioning/thin_ll_restore.cc +++ b/thin-provisioning/thin_ll_restore.cc @@ -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':