Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions score/kvs/kvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ score::Result<void> Kvs::SetValueToDefault(const std::string_view key) noexcept

score::Result<bool> Kvs::IsValueDefault(const std::string_view key) const noexcept
{
std::unique_lock<std::mutex> lock(kvs_mutex_, std::try_to_lock);
std::unique_lock<std::mutex> lock{kvs_mutex_, std::try_to_lock};
if (!lock.owns_lock())
{
GetLogger().LogWarn() << "Failed to lock KVS mutex";
Expand Down Expand Up @@ -599,7 +599,7 @@ score::Result<void> Kvs::SnapshotRestore(const SnapshotId& snapshot_id) noexcept
}

// Fail if the snapshot ID is the current KVS or does not exist.
if ((0 == snapshot_id.id) || (*snapshot_count_result < snapshot_id.id))
if ((snapshot_id.id == 0U) || (*snapshot_count_result < snapshot_id.id))
{
GetLogger().LogError() << "Invalid snapshot ID" << snapshot_id.id;
return score::MakeUnexpected(ErrorCode::kInvalidSnapshotId);
Expand Down
10 changes: 5 additions & 5 deletions score/kvs/kvs_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ KvsBuilder::KvsBuilder(const InstanceId& instance_id) noexcept

KvsBuilder& KvsBuilder::Snapshot(const SnapshotId& snapshot_id) noexcept
{
this->snapshot_id_ = snapshot_id;
snapshot_id_ = snapshot_id;
return *this;
}

Expand All @@ -47,26 +47,26 @@ KvsBuilder& KvsBuilder::KvsLoad(const score::kvs::KvsLoad& mode) noexcept

KvsBuilder& KvsBuilder::WorkingDir(const std::string& working_dir) noexcept
{
this->working_dir_ = working_dir;
working_dir_ = working_dir;
return *this;
}

KvsBuilder& KvsBuilder::MaxStorageBytes(const std::optional<size_t>& max_storage_bytes) noexcept
{
this->maximum_storage_bytes_ = max_storage_bytes;
maximum_storage_bytes_ = max_storage_bytes;
return *this;
}

KvsBuilder& KvsBuilder::SnapshotMaxCount(const std::size_t max_count) noexcept
{
this->max_snapshots_ = max_count;
max_snapshots_ = max_count;
return *this;
}

score::Result<Kvs> KvsBuilder::Build() const noexcept
{
// Use current directory if empty.
const std::string working_dir = working_dir_.empty() ? std::string{"./"} : working_dir_;
const std::string working_dir{working_dir_.empty() ? std::string{"./"} : working_dir_};
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

return Kvs::Open(
instance_id_, snapshot_id_, defaults_, kvs_load_, working_dir, maximum_storage_bytes_, max_snapshots_);
Expand Down
8 changes: 5 additions & 3 deletions score/kvs/kvs_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

#include "score/kvs/kvs_general_test.h"

using namespace score::kvs;

namespace
{
void remove_file(const std::string& path)
void RemoveFile(const std::string& path)
{
score::cpp::ignore = score::filesystem::FilesystemFactory{}.CreateInstance().standard->Remove(path);
}
Expand Down Expand Up @@ -121,8 +123,8 @@ TEST(kvs_kvsbuilder, kvsbuilder_directory_check)
ASSERT_TRUE(kvs.Flush());

auto filename{kvs.KvsFilePath(SnapshotId{0ul})};
remove_file(expected_prefix + ".json");
remove_file(expected_prefix + ".hash");
RemoveFile(expected_prefix + ".json");
RemoveFile(expected_prefix + ".hash");
ASSERT_TRUE(filename);
EXPECT_EQ(filename.value().CStr(), expected_prefix + ".json");
}
Expand Down
2 changes: 2 additions & 0 deletions score/kvs/kvs_deprecated_api_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ DISABLE_WARNING(-Wdeprecated-declarations)
#include "score/kvs/kvsvalue.hpp"
DISABLE_WARNING_POP

using namespace score::kvs;

namespace
{

Expand Down
2 changes: 2 additions & 0 deletions score/kvs/kvs_error_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "score/kvs/kvs_general_test.h"

using namespace score::kvs;

namespace
{
constexpr score::kvs::KvsErrorDomain kKvsErrorDomain;
Expand Down
2 changes: 2 additions & 0 deletions score/kvs/kvs_general_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "score/kvs/kvs_general_test.h"

using namespace score::kvs;

/// @brief Independent Adler-32 implementation to check the KVS hash against.
uint32_t Adler32(const std::string& data)
{
Expand Down
5 changes: 2 additions & 3 deletions score/kvs/kvs_general_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "score/json/i_json_writer_mock.h"
#include "score/kvs/internal/kvs_helper.h"
#include "score/kvs/kvs_builder.h"
using namespace score::kvs;

uint32_t Adler32(const std::string& data);
void PrepareEnvironment();
Expand Down Expand Up @@ -84,8 +83,8 @@ inline void PrepareEnvironment(const std::string& dir,
// Default data used in unit tests.

const std::uint32_t kInstance{123U};
const InstanceId kInstanceId{kInstance};
const SnapshotId kSnapshotId{0ul};
const score::kvs::InstanceId kInstanceId{kInstance};
const score::kvs::SnapshotId kSnapshotId{0ul};

// score::filesystem::Path could be constructed implicitly from std::string.
// For readability, the test code constructs it explicitly from these strings.
Expand Down
2 changes: 2 additions & 0 deletions score/kvs/kvs_helper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "score/kvs/kvs_general_test.h"

using namespace score::kvs;

TEST(kvs_calculate_hash_adler32, calculate_hash_adler32)
{
// Test the Adler-32 hash calculation.
Expand Down
Loading
Loading