fix up some coverity issues

This commit is contained in:
Joe Thornber 2013-08-15 16:26:17 +01:00
parent 77286e0bc7
commit 500e508c6d
9 changed files with 43 additions and 11 deletions

View File

@ -65,7 +65,6 @@ namespace persistent_data {
int fd_;
block_address nr_blocks_;
mode mode_;
bool writeable_;
};
template <uint32_t BlockSize = MD_BLOCK_SIZE>

View File

@ -68,15 +68,29 @@ namespace base {
v_(v) {
}
struct {
value_entry *next_, *prev_;
} lru_;
struct lru {
lru()
: next_(0),
prev_(0) {
}
value_entry *next_, *prev_;
};
struct lookup {
lookup()
: parent_(0),
left_(0),
right_(0),
color_() {
}
struct {
value_entry *parent_, *left_, *right_;
int color_;
} lookup_;
};
lru lru_;
lookup lookup_;
unsigned ref_count_;
value_type v_;
};

View File

@ -235,6 +235,7 @@ namespace persistent_data {
public:
typedef transaction_manager::read_ref read_ref;
typedef transaction_manager::write_ref write_ref;
typedef boost::optional<block_address> maybe_block;
shadow_spine(transaction_manager::ptr tm,
block_manager<>::validator::ptr v)
@ -282,14 +283,17 @@ namespace persistent_data {
}
block_address get_root() const {
return root_;
if (root_)
return *root_;
throw std::runtime_error("shadow spine has no root");
}
private:
transaction_manager::ptr tm_;
block_manager<>::validator::ptr validator_;
std::list<block_manager<>::write_ref> spine_;
block_address root_;
maybe_block root_;
};
// Used to keep a record of a nested btree's position.

View File

@ -29,6 +29,8 @@ void base::hex_dump(ostream &out, void const *data_, size_t len)
{
unsigned char const *data = reinterpret_cast<unsigned char const *>(data_),
*end = data + len;
ios_base::fmtflags old_flags = out.flags();
out << hex;
while (data < end) {
@ -36,7 +38,8 @@ void base::hex_dump(ostream &out, void const *data_, size_t len)
out << setw(2) << setfill('0') << (unsigned) *data << " ";
out << endl;
}
out << dec;
out.setf(old_flags);
}
//----------------------------------------------------------------

View File

@ -40,6 +40,7 @@ namespace {
md_sm_(md_sm),
data_sm_(data_sm),
in_range_(false),
time_(),
found_errors_(false) {
}

View File

@ -32,6 +32,7 @@ namespace {
restorer(metadata::ptr md)
: md_(md),
in_superblock_(false),
nr_data_blocks_(),
empty_mapping_(new_mapping_tree()) {
}

View File

@ -37,6 +37,7 @@ superblock_traits::unpack(superblock_disk const &disk, superblock &value)
value.metadata_nr_blocks_ = to_cpu<uint64_t>(disk.metadata_nr_blocks_);
value.compat_flags_ = to_cpu<uint32_t>(disk.compat_flags_);
value.compat_ro_flags_ = to_cpu<uint32_t>(disk.compat_ro_flags_);
value.incompat_flags_ = to_cpu<uint32_t>(disk.incompat_flags_);
}
@ -70,6 +71,7 @@ superblock_traits::pack(superblock const &value, superblock_disk &disk)
disk.metadata_nr_blocks_ = to_disk<le64>(value.metadata_nr_blocks_);
disk.compat_flags_ = to_disk<le32>(value.compat_flags_);
disk.compat_ro_flags_ = to_disk<le32>(value.compat_ro_flags_);
disk.incompat_flags_ = to_disk<le32>(value.incompat_flags_);
}

View File

@ -216,7 +216,8 @@ namespace {
class mapping_reporter : public mapping_tree_detail::damage_visitor {
public:
mapping_reporter(nested_output &out)
: out_(out) {
: out_(out),
err_(NO_ERROR) {
}
virtual void visit(mapping_tree_detail::missing_devices const &d) {

View File

@ -150,7 +150,14 @@ int main(int argc, char **argv)
case 1:
// region
regions.push_back(parse_region(optarg));
try {
regions.push_back(parse_region(optarg));
} catch (std::exception const &e) {
cerr << e.what();
return 1;
}
break;
default: