From e6d393563694c2ce0686ddcf450abd6e837ac076 Mon Sep 17 00:00:00 2001 From: Nobuhiro Ban Date: Sun, 8 Oct 2023 13:27:05 +0900 Subject: [PATCH] cleanup: reduce NOLINT --- include/limestone/api/datastore.h | 2 +- src/limestone/datastore.cpp | 14 +++++++------- src/limestone/datastore_snapshot.cpp | 8 ++++---- src/limestone/log_channel.cpp | 4 ++-- src/limestone/log_entry.h | 16 ++++++++-------- src/limestone/logging_helper.h | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/limestone/api/datastore.h b/include/limestone/api/datastore.h index af2173ba..cc85b4cd 100644 --- a/include/limestone/api/datastore.h +++ b/include/limestone/api/datastore.h @@ -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, diff --git a/src/limestone/datastore.cpp b/src/limestone/datastore.cpp index 07885d22..443cec84 100644 --- a/src/limestone/datastore.cpp +++ b/src/limestone/datastore.cpp @@ -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())) { @@ -55,12 +55,12 @@ 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 } @@ -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 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(); @@ -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(); } @@ -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(); } diff --git a/src/limestone/datastore_snapshot.cpp b/src/limestone/datastore_snapshot.cpp index c7b95560..0aff7caf 100644 --- a/src/limestone/datastore_snapshot.cpp +++ b/src/limestone/datastore_snapshot.cpp @@ -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(dest); // NOLINT - auto* p64_src = reinterpret_cast(src); // NOLINT + auto* p64_dest = reinterpret_cast(dest); // NOLINT(*-reinterpret-cast) + auto* p64_src = reinterpret_cast(src); // NOLINT(*-reinterpret-cast) *p64_dest = __bswap_64(*p64_src); } @@ -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(); @@ -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(); } diff --git a/src/limestone/log_channel.cpp b/src/limestone/log_channel.cpp index f37c32ee..6155d513 100644 --- a/src/limestone/log_channel.cpp +++ b/src/limestone/log_channel.cpp @@ -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(); @@ -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(); } diff --git a/src/limestone/log_entry.h b/src/limestone/log_entry.h index f6bd0703..ab880359 100644 --- a/src/limestone/log_entry.h +++ b/src/limestone/log_entry.h @@ -92,11 +92,11 @@ class log_entry { write_uint8(strm, static_cast(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(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(value_len)); write_uint64le(strm, static_cast(storage_id)); @@ -112,11 +112,11 @@ class log_entry { write_uint8(strm, static_cast(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(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(value_len)); write_bytes(strm, key_sid.data(), key_sid.length()); @@ -128,7 +128,7 @@ class log_entry { write_uint8(strm, static_cast(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(key_len)); write_uint64le(strm, static_cast(storage_id)); @@ -143,7 +143,7 @@ class log_entry { write_uint8(strm, static_cast(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(key_len)); write_bytes(strm, key_sid.data(), key_sid.length()); @@ -252,7 +252,7 @@ class log_entry { } static std::uint32_t read_uint32le(std::istream& in) { std::uint32_t buf{}; - in.read(reinterpret_cast(&buf), sizeof(std::uint32_t)); // NOLINT + in.read(reinterpret_cast(&buf), sizeof(std::uint32_t)); // NOLINT(*-reinterpret-cast) return le32toh(buf); } static void write_uint64le(FILE* out, const std::uint64_t value) { @@ -261,7 +261,7 @@ class log_entry { } static std::uint64_t read_uint64le(std::istream& in) { std::uint64_t buf{}; - in.read(reinterpret_cast(&buf), sizeof(std::uint64_t)); // NOLINT + in.read(reinterpret_cast(&buf), sizeof(std::uint64_t)); // NOLINT(*-reinterpret-cast) return le64toh(buf); } static void write_bytes(FILE* out, const void* buf, std::size_t len) { diff --git a/src/limestone/logging_helper.h b/src/limestone/logging_helper.h index 854cbcd1..9ed8e292 100644 --- a/src/limestone/logging_helper.h +++ b/src/limestone/logging_helper.h @@ -85,8 +85,8 @@ constexpr auto location_prefix(const std::string_view sv) { } template -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(sv); }