Skip to content

Commit

Permalink
cleanup: reduce NOLINT
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Oct 10, 2023
1 parent 84ca803 commit b14bc69
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/limestone/api/datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class datastore {
/**
* @brief name of a file to record durable epoch
*/
static constexpr const std::string_view epoch_file_name = "epoch"; // NOLINT
static constexpr const std::string_view epoch_file_name = "epoch";

enum class state : std::int64_t {
not_ready = 0,
Expand Down
16 changes: 8 additions & 8 deletions src/limestone/datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ datastore::datastore(configuration const& conf) : location_(conf.data_locations_
const bool result_mkdir = boost::filesystem::create_directory(location_, error);
if (!result_mkdir || error) {
LOG_LP(ERROR) << "fail to create directory: result_mkdir: " << result_mkdir << ", error_code: " << error << ", path: " << location_;
throw std::runtime_error("fail to create the log_location directory"); //NOLINT
throw std::runtime_error("fail to create the log_location directory");
}
} else {
BOOST_FOREACH(const boost::filesystem::path& p, std::make_pair(boost::filesystem::directory_iterator(location_), boost::filesystem::directory_iterator())) {
Expand All @@ -55,14 +55,14 @@ datastore::datastore(configuration const& conf) : location_(conf.data_locations_
epoch_file_path_ = location_ / boost::filesystem::path(std::string(epoch_file_name));
const bool result = boost::filesystem::exists(epoch_file_path_, error);
if (!result || error) {
FILE* strm = fopen(epoch_file_path_.c_str(), "a"); // NOLINT
FILE* strm = fopen(epoch_file_path_.c_str(), "a"); // NOLINT(*-owning-memory)
if (!strm) {
LOG_LP(ERROR) << "does not have write permission for the log_location directory, path: " << location_;
throw std::runtime_error("does not have write permission for the log_location directory"); //NOLINT
throw std::runtime_error("does not have write permission for the log_location directory");
}
if (fclose(strm) != 0) { // NOLINT
if (fclose(strm) != 0) { // NOLINT(*-owning-memory)
LOG_LP(ERROR) << "fclose failed, errno = " << errno;
throw std::runtime_error("I/O error"); //NOLINT
throw std::runtime_error("I/O error");
}
add_file(epoch_file_path_);
}
Expand Down Expand Up @@ -146,7 +146,7 @@ void datastore::update_min_epoch_id(bool from_switch_epoch) noexcept { // NOLIN
if (epoch_id_recorded_.compare_exchange_strong(old_epoch_id, to_be_epoch)) {
std::lock_guard<std::mutex> lock(mtx_epoch_file_);

FILE* strm = fopen(epoch_file_path_.c_str(), "a"); // NOLINT
FILE* strm = fopen(epoch_file_path_.c_str(), "a"); // NOLINT(*-owning-memory)
if (!strm) {
LOG_LP(ERROR) << "fopen failed, errno = " << errno;
std::abort();
Expand All @@ -160,7 +160,7 @@ void datastore::update_min_epoch_id(bool from_switch_epoch) noexcept { // NOLIN
LOG_LP(ERROR) << "fsync failed, errno = " << errno;
std::abort();
}
if (fclose(strm) != 0) { // NOLINT
if (fclose(strm) != 0) { // NOLINT(*-owning-memory)
LOG_LP(ERROR) << "fclose failed, errno = " << errno;
std::abort();
}
Expand Down Expand Up @@ -342,7 +342,7 @@ void datastore::rotate_epoch_file() {
strm.open(epoch_file_path_, std::ios_base::out | std::ios_base::app | std::ios_base::binary);
if(!strm || !strm.is_open() || strm.bad() || strm.fail()){
LOG_LP(ERROR) << "does not have write permission for the log_location directory, path: " << location_;
throw std::runtime_error("does not have write permission for the log_location directory"); //NOLINT
throw std::runtime_error("does not have write permission for the log_location directory");
}
strm.close();
}
Expand Down
8 changes: 4 additions & 4 deletions src/limestone/datastore_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ epoch_id_type datastore::last_durable_epoch_in_dir() noexcept {

[[maybe_unused]]
static void store_bswap64_value(void *dest, const void *src) {
auto* p64_dest = reinterpret_cast<std::uint64_t*>(dest); // NOLINT
auto* p64_src = reinterpret_cast<const std::uint64_t*>(src); // NOLINT
auto* p64_dest = reinterpret_cast<std::uint64_t*>(dest); // NOLINT(*-reinterpret-cast)
auto* p64_src = reinterpret_cast<const std::uint64_t*>(src); // NOLINT(*-reinterpret-cast)
*p64_dest = __bswap_64(*p64_src);
}

Expand Down Expand Up @@ -214,7 +214,7 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog

boost::filesystem::path snapshot_file = sub_dir / boost::filesystem::path(std::string(snapshot::file_name_));
VLOG_LP(log_info) << "generating snapshot file: " << snapshot_file;
FILE* ostrm = fopen(snapshot_file.c_str(), "w"); // NOLINT
FILE* ostrm = fopen(snapshot_file.c_str(), "w"); // NOLINT(*-owning-memory)
if (!ostrm) {
LOG_LP(ERROR) << "cannot create snapshot file (" << snapshot_file << ")";
std::abort();
Expand Down Expand Up @@ -264,7 +264,7 @@ void datastore::create_snapshot() noexcept { // NOLINT(readability-function-cog
}
});
#endif
if (fclose(ostrm) != 0) { // NOLINT
if (fclose(ostrm) != 0) { // NOLINT(*-owning-memory)
LOG_LP(ERROR) << "cannot close snapshot file (" << snapshot_file << "), errno = " << errno;
std::abort();
}
Expand Down
4 changes: 2 additions & 2 deletions src/limestone/log_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void log_channel::begin_session() noexcept {
} while (current_epoch_id_.load() != envelope_.epoch_id_switched_.load());

auto log_file = file_path();
strm_ = fopen(log_file.c_str(), "a"); // NOLINT
strm_ = fopen(log_file.c_str(), "a"); // NOLINT(*-owning-memory)
if (!strm_) {
LOG_LP(ERROR) << "I/O error, cannot make file on " << location_ << ", errno = " << errno;
std::abort();
Expand All @@ -69,7 +69,7 @@ void log_channel::end_session() noexcept {
finished_epoch_id_.store(current_epoch_id_.load());
current_epoch_id_.store(UINT64_MAX);
envelope_.update_min_epoch_id();
if (fclose(strm_) != 0) { // NOLINT
if (fclose(strm_) != 0) { // NOLINT(*-owning-memory)
LOG_LP(ERROR) << "fclose failed, errno = " << errno;
std::abort();
}
Expand Down
16 changes: 8 additions & 8 deletions src/limestone/log_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class log_entry {
write_uint8(strm, static_cast<std::uint8_t>(type));

std::size_t key_len = key.length();
assert(key_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(key_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(key_len));

std::size_t value_len = value.length();
assert(value_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(value_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(value_len));

write_uint64le(strm, static_cast<std::uint64_t>(storage_id));
Expand All @@ -112,11 +112,11 @@ class log_entry {
write_uint8(strm, static_cast<std::uint8_t>(type));

std::size_t key_len = key_sid.length() - sizeof(storage_id_type);
assert(key_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(key_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(key_len));

std::size_t value_len = value_etc.length() - (sizeof(epoch_id_type) + sizeof(std::uint64_t));
assert(value_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(value_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(value_len));

write_bytes(strm, key_sid.data(), key_sid.length());
Expand All @@ -128,7 +128,7 @@ class log_entry {
write_uint8(strm, static_cast<std::uint8_t>(type));

std::size_t key_len = key.length();
assert(key_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(key_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(key_len));

write_uint64le(strm, static_cast<std::uint64_t>(storage_id));
Expand All @@ -143,7 +143,7 @@ class log_entry {
write_uint8(strm, static_cast<std::uint8_t>(type));

std::size_t key_len = key_sid.length() - sizeof(storage_id_type);
assert(key_len <= UINT32_MAX); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
assert(key_len <= UINT32_MAX);
write_uint32le(strm, static_cast<std::uint32_t>(key_len));

write_bytes(strm, key_sid.data(), key_sid.length());
Expand Down Expand Up @@ -252,7 +252,7 @@ class log_entry {
}
static std::uint32_t read_uint32le(std::istream& in) {
std::uint32_t buf{};
in.read(reinterpret_cast<char*>(&buf), sizeof(std::uint32_t)); // NOLINT
in.read(reinterpret_cast<char*>(&buf), sizeof(std::uint32_t)); // NOLINT(*-reinterpret-cast)
return le32toh(buf);
}
static void write_uint64le(FILE* out, const std::uint64_t value) {
Expand All @@ -261,7 +261,7 @@ class log_entry {
}
static std::uint64_t read_uint64le(std::istream& in) {
std::uint64_t buf{};
in.read(reinterpret_cast<char*>(&buf), sizeof(std::uint64_t)); // NOLINT
in.read(reinterpret_cast<char*>(&buf), sizeof(std::uint64_t)); // NOLINT(*-reinterpret-cast)
return le64toh(buf);
}
static void write_bytes(FILE* out, const void* buf, std::size_t len) {
Expand Down
4 changes: 2 additions & 2 deletions src/limestone/logging_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ constexpr auto location_prefix(const std::string_view sv) {
}

template<size_t N, size_t M>
constexpr auto location_prefix(const char (&prettyname)[N], const char (&funcname)[M]) { // NOLINT
const std::string_view sv = find_fullname(prettyname, funcname); // NOLINT
constexpr auto location_prefix(const char (&prettyname)[N], const char (&funcname)[M]) { // NOLINT(*-avoid-c-arrays)
const std::string_view sv = find_fullname(prettyname, funcname); // NOLINT(*-bounds-array-to-pointer-decay)
return location_prefix<std::max(N, M)>(sv);
}

Expand Down

0 comments on commit b14bc69

Please sign in to comment.