Skip to content

Commit

Permalink
[vm] use int type to track snapshot details
Browse files Browse the repository at this point in the history
  • Loading branch information
sharder996 authored and ricab committed Jun 23, 2023
1 parent ee1b5a5 commit e327953
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/platform/backends/shared/base_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace
constexpr auto snapshot_extension = "snapshot.json";
constexpr auto head_filename = "snapshot-head";
constexpr auto count_filename = "snapshot-count";
constexpr auto index_digits = 4; // these two go together
constexpr auto max_snapshots = 1000ull; // replace suffix with uz for size_t in C++23
constexpr auto index_digits = 4; // these two go together
constexpr auto max_snapshots = 1000;
constexpr auto yes_overwrite = true;
} // namespace

Expand Down Expand Up @@ -112,7 +112,7 @@ std::shared_ptr<const Snapshot> BaseVirtualMachine::get_snapshot(const std::stri
}

void BaseVirtualMachine::take_snapshot_rollback_helper(SnapshotMap::iterator it, std::shared_ptr<Snapshot>& old_head,
size_t old_count)
int old_count)
{
if (old_head != head_snapshot)
{
Expand Down Expand Up @@ -188,7 +188,7 @@ void BaseVirtualMachine::load_generic_snapshot_info(const QDir& snapshot_dir)
{
try
{
snapshot_count = std::stoull(mpu::contents_of(snapshot_dir.filePath(count_filename)));
snapshot_count = std::stoi(mpu::contents_of(snapshot_dir.filePath(count_filename)));
head_snapshot = snapshots.at(mpu::contents_of(snapshot_dir.filePath(head_filename)));
}
catch (FileOpenFailedException&)
Expand All @@ -201,7 +201,7 @@ void BaseVirtualMachine::load_generic_snapshot_info(const QDir& snapshot_dir)
template <typename LockT>
void BaseVirtualMachine::log_latest_snapshot(LockT lock) const
{
auto num_snapshots = snapshots.size();
auto num_snapshots = static_cast<int>(snapshots.size());
auto parent_name = head_snapshot->get_parent_name();

assert(num_snapshots <= snapshot_count && "can't have more snapshots than were ever taken");
Expand Down
4 changes: 2 additions & 2 deletions src/platform/backends/shared/base_virtual_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class BaseVirtualMachine : public VirtualMachine
void load_snapshot(const QJsonObject& json);

auto make_take_snapshot_rollback(SnapshotMap::iterator it);
void take_snapshot_rollback_helper(SnapshotMap::iterator it, std::shared_ptr<Snapshot>& old_head, size_t old_count);
void take_snapshot_rollback_helper(SnapshotMap::iterator it, std::shared_ptr<Snapshot>& old_head, int old_count);

auto make_head_file_rollback(const QString& head_path, QFile& head_file) const;
void head_file_rollback_helper(const QString& head_path, QFile& head_file, const std::string& old_head,
Expand All @@ -103,7 +103,7 @@ class BaseVirtualMachine : public VirtualMachine
private:
SnapshotMap snapshots;
std::shared_ptr<Snapshot> head_snapshot = nullptr;
size_t snapshot_count = 0; // tracks the number of snapshots ever taken (regardless or deletes)
int snapshot_count = 0; // tracks the number of snapshots ever taken (regardless or deletes)
mutable std::recursive_mutex snapshot_mutex;
};

Expand Down

0 comments on commit e327953

Please sign in to comment.