From cc125647acc986a364685eaaea733d670de69035 Mon Sep 17 00:00:00 2001 From: tkaya Date: Sun, 13 Dec 2020 15:13:25 +0100 Subject: [PATCH] Adjusted usage of nested namespaces in codebase --- include/client/hooks.hpp | 6 ++---- include/client/rpc/forward_metadata.hpp | 1 - include/client/rpc/rpc_types.hpp | 12 ++++-------- include/client/syscalls/args.hpp | 8 ++------ include/client/syscalls/decoder.hpp | 6 ++---- include/client/syscalls/errno.hpp | 6 ++---- include/client/syscalls/rets.hpp | 8 ++------ include/client/syscalls/syscall.hpp | 6 ++---- include/common/env_util.hpp | 6 ++---- include/daemon/backend/data/chunk_storage.hpp | 6 ++---- include/daemon/backend/data/data_module.hpp | 6 ++---- include/daemon/backend/data/file_handle.hpp | 6 ++---- include/daemon/backend/exceptions.hpp | 6 ++---- include/daemon/backend/metadata/merge.hpp | 6 ++---- include/daemon/env.hpp | 6 ++---- include/daemon/ops/metadentry.hpp | 6 ++---- include/daemon/util.hpp | 6 ++---- src/client/logging.cpp | 6 ++---- src/client/open_dir.cpp | 6 ++---- src/client/open_file_map.cpp | 6 ++---- src/client/path.cpp | 6 ++---- src/client/rpc/forward_management.cpp | 6 ++---- src/client/rpc/forward_metadata.cpp | 6 ++---- src/daemon/backend/metadata/merge.cpp | 6 ++---- src/daemon/ops/data.cpp | 6 ++---- 25 files changed, 50 insertions(+), 105 deletions(-) diff --git a/include/client/hooks.hpp b/include/client/hooks.hpp index 5616ea3b5..9eca42262 100644 --- a/include/client/hooks.hpp +++ b/include/client/hooks.hpp @@ -37,8 +37,7 @@ struct statfs; struct linux_dirent; struct linux_dirent64; -namespace gkfs { -namespace hook { +namespace gkfs::hook { int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); @@ -164,7 +163,6 @@ hook_fstatfs(unsigned int fd, struct statfs* buf); int hook_fsync(unsigned int fd); -} // namespace hook -} // namespace gkfs +} // namespace gkfs::hook #endif diff --git a/include/client/rpc/forward_metadata.hpp b/include/client/rpc/forward_metadata.hpp index 3d83d0b7f..7b88efcc6 100644 --- a/include/client/rpc/forward_metadata.hpp +++ b/include/client/rpc/forward_metadata.hpp @@ -86,7 +86,6 @@ forward_mk_symlink(const std::string& path, const std::string& target_path); #endif - } // namespace rpc } // namespace gkfs diff --git a/include/client/rpc/rpc_types.hpp b/include/client/rpc/rpc_types.hpp index 973e34727..34d5cfa5b 100644 --- a/include/client/rpc/rpc_types.hpp +++ b/include/client/rpc/rpc_types.hpp @@ -49,8 +49,7 @@ #include #include -namespace hermes { -namespace detail { +namespace hermes::detail { struct hg_void_t {}; @@ -62,11 +61,9 @@ hg_proc_void_t(hg_proc_t proc, void* data) { return HG_SUCCESS; } -} // namespace detail -} // namespace hermes +} // namespace hermes::detail -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { //============================================================================== // definitions for fs_config @@ -2283,8 +2280,7 @@ struct chunk_stat { }; }; -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc #endif // GKFS_RPCS_TYPES_HPP diff --git a/include/client/syscalls/args.hpp b/include/client/syscalls/args.hpp index 474f89def..79406754b 100644 --- a/include/client/syscalls/args.hpp +++ b/include/client/syscalls/args.hpp @@ -47,9 +47,7 @@ #include #include -namespace gkfs { -namespace syscall { -namespace arg { +namespace gkfs::syscall::arg { /** Allowed arg types (based on the values of the corresponding C enum) */ enum class type { @@ -717,9 +715,7 @@ format_arg_to(FmtBuffer& buffer, const printable_arg& parg) { #undef LIKELY #undef UNLIKELY -} // namespace arg -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall::arg #endif // GKFS_SYSCALLS_ARGS_HPP diff --git a/include/client/syscalls/decoder.hpp b/include/client/syscalls/decoder.hpp index 6fbf779ad..45a141bc3 100644 --- a/include/client/syscalls/decoder.hpp +++ b/include/client/syscalls/decoder.hpp @@ -34,8 +34,7 @@ #include #include -namespace gkfs { -namespace syscall { +namespace gkfs::syscall { namespace detail { @@ -113,7 +112,6 @@ decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS], ret.formatter()(buffer, result); } -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall #endif // GKFS_SYSCALLS_DECODER_HPP \ No newline at end of file diff --git a/include/client/syscalls/errno.hpp b/include/client/syscalls/errno.hpp index 624dc9c0b..088bea6b3 100644 --- a/include/client/syscalls/errno.hpp +++ b/include/client/syscalls/errno.hpp @@ -33,8 +33,7 @@ #include #include -namespace gkfs { -namespace syscall { +namespace gkfs::syscall { static const std::array errno_names = { /* [ 0] = */ NULL, @@ -591,7 +590,6 @@ errno_message(int errno_value) { return std::string{msg}; } -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall #endif // GKFS_SYSCALLS_ERRNO_HPP diff --git a/include/client/syscalls/rets.hpp b/include/client/syscalls/rets.hpp index f41739984..6ff4bb5d4 100644 --- a/include/client/syscalls/rets.hpp +++ b/include/client/syscalls/rets.hpp @@ -37,9 +37,7 @@ #include #include -namespace gkfs { -namespace syscall { -namespace ret { +namespace gkfs::syscall::ret { /** Allowed ret types (based on the values of the corresponding C enum) */ enum class type { @@ -148,9 +146,7 @@ format_dec_ret_to(FmtBuffer& buffer, #undef LIKELY #undef UNLIKELY -} // namespace ret -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall::ret #endif // GKFS_SYSCALLS_RETS_HPP diff --git a/include/client/syscalls/syscall.hpp b/include/client/syscalls/syscall.hpp index 8efb1fa35..a85b3ddd4 100644 --- a/include/client/syscalls/syscall.hpp +++ b/include/client/syscalls/syscall.hpp @@ -38,8 +38,7 @@ #include #include -namespace gkfs { -namespace syscall { +namespace gkfs::syscall { static const auto constexpr MAX_ARGS = 6u; using arg_list = std::array; @@ -228,8 +227,7 @@ error_code(long result) { return 0; } -} // namespace syscall -} // namespace gkfs +} // namespace gkfs::syscall #endif // GKFS_SYSCALL_HPP diff --git a/include/common/env_util.hpp b/include/common/env_util.hpp index 937bbc01f..7c3534568 100644 --- a/include/common/env_util.hpp +++ b/include/common/env_util.hpp @@ -31,13 +31,11 @@ #include -namespace gkfs { -namespace env { +namespace gkfs::env { std::string get_var(const std::string& name, const std::string& default_value = ""); -} // namespace env -} // namespace gkfs +} // namespace gkfs::env #endif // GKFS_COMMON_ENV_UTIL_HPP diff --git a/include/daemon/backend/data/chunk_storage.hpp b/include/daemon/backend/data/chunk_storage.hpp index dd6f7ee68..873302fff 100644 --- a/include/daemon/backend/data/chunk_storage.hpp +++ b/include/daemon/backend/data/chunk_storage.hpp @@ -41,8 +41,7 @@ namespace spdlog { class logger; } -namespace gkfs { -namespace data { +namespace gkfs::data { struct ChunkStat { unsigned long chunk_size; @@ -101,7 +100,6 @@ public: chunk_stat() const; }; -} // namespace data -} // namespace gkfs +} // namespace gkfs::data #endif // GEKKOFS_CHUNK_STORAGE_HPP diff --git a/include/daemon/backend/data/data_module.hpp b/include/daemon/backend/data/data_module.hpp index 83181ae03..73bbecd33 100644 --- a/include/daemon/backend/data/data_module.hpp +++ b/include/daemon/backend/data/data_module.hpp @@ -31,8 +31,7 @@ #include -namespace gkfs { -namespace data { +namespace gkfs::data { class DataModule { @@ -66,7 +65,6 @@ public: (static_cast( \ gkfs::data::DataModule::getInstance())) -} // namespace data -} // namespace gkfs +} // namespace gkfs::data #endif // GEKKOFS_DAEMON_DATA_LOGGING_HPP diff --git a/include/daemon/backend/data/file_handle.hpp b/include/daemon/backend/data/file_handle.hpp index 65b151cc4..2a5c85d4e 100644 --- a/include/daemon/backend/data/file_handle.hpp +++ b/include/daemon/backend/data/file_handle.hpp @@ -35,8 +35,7 @@ extern "C" { #include } -namespace gkfs { -namespace data { +namespace gkfs::data { /** * File handle to encapsulate a file descriptor, allowing RAII closing of the @@ -108,8 +107,7 @@ public: } }; -} // namespace data -} // namespace gkfs +} // namespace gkfs::data #endif // GEKKOFS_DAEMON_FILE_HANDLE_HPP diff --git a/include/daemon/backend/exceptions.hpp b/include/daemon/backend/exceptions.hpp index 38da51dad..6a992d9a7 100644 --- a/include/daemon/backend/exceptions.hpp +++ b/include/daemon/backend/exceptions.hpp @@ -32,8 +32,7 @@ #include #include -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { class DBException : public std::runtime_error { public: @@ -50,7 +49,6 @@ public: explicit ExistsException(const std::string& s) : DBException(s){}; }; -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata #endif // GEKKOFS_DB_EXCEPTIONS_HPP diff --git a/include/daemon/backend/metadata/merge.hpp b/include/daemon/backend/metadata/merge.hpp index dcd2b4a26..4189e6804 100644 --- a/include/daemon/backend/metadata/merge.hpp +++ b/include/daemon/backend/metadata/merge.hpp @@ -35,8 +35,7 @@ namespace rdb = rocksdb; -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { enum class OperandID : char { increase_size = 'i', @@ -137,7 +136,6 @@ public: AllowSingleOperand() const override; }; -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata #endif // DB_MERGE_HPP diff --git a/include/daemon/env.hpp b/include/daemon/env.hpp index 317ca7189..0ff8ff03b 100644 --- a/include/daemon/env.hpp +++ b/include/daemon/env.hpp @@ -34,13 +34,11 @@ #define ADD_PREFIX(str) DAEMON_ENV_PREFIX str /* Environment variables for the GekkoFS daemon */ -namespace gkfs { -namespace env { +namespace gkfs::env { static constexpr auto HOSTS_FILE = ADD_PREFIX("HOSTS_FILE"); -} // namespace env -} // namespace gkfs +} // namespace gkfs::env #undef ADD_PREFIX diff --git a/include/daemon/ops/metadentry.hpp b/include/daemon/ops/metadentry.hpp index aabcdbc49..4665be86a 100644 --- a/include/daemon/ops/metadentry.hpp +++ b/include/daemon/ops/metadentry.hpp @@ -32,8 +32,7 @@ #include #include -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { Metadata get(const std::string& path); @@ -62,7 +61,6 @@ update_size(const std::string& path, size_t io_size, off_t offset, bool append); void remove(const std::string& path); -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata #endif // GEKKOFS_METADENTRY_HPP diff --git a/include/daemon/util.hpp b/include/daemon/util.hpp index 4c907f4f8..9d10a5f5c 100644 --- a/include/daemon/util.hpp +++ b/include/daemon/util.hpp @@ -29,14 +29,12 @@ #ifndef GEKKOFS_DAEMON_UTIL_HPP #define GEKKOFS_DAEMON_UTIL_HPP -namespace gkfs { -namespace utils { +namespace gkfs::utils { void populate_hosts_file(); void destroy_hosts_file(); -} // namespace utils -} // namespace gkfs +} // namespace gkfs::utils #endif // GEKKOFS_DAEMON_UTIL_HPP diff --git a/src/client/logging.cpp b/src/client/logging.cpp index 0b45cb458..dc09908a4 100644 --- a/src/client/logging.cpp +++ b/src/client/logging.cpp @@ -44,8 +44,7 @@ extern "C" { #endif -namespace gkfs { -namespace log { +namespace gkfs::log { struct opt_info { const char name_[32]; @@ -471,5 +470,4 @@ print_syscall: ::syscall_no_intercept(SYS_write, log_fd_, buffer.data(), buffer.size()); } -} // namespace log -} // namespace gkfs +} // namespace gkfs::log diff --git a/src/client/open_dir.cpp b/src/client/open_dir.cpp index a41b3c518..20d7344a1 100644 --- a/src/client/open_dir.cpp +++ b/src/client/open_dir.cpp @@ -31,8 +31,7 @@ #include #include -namespace gkfs { -namespace filemap { +namespace gkfs::filemap { DirEntry::DirEntry(const std::string& name, const FileType type) : name_(name), type_(type) {} @@ -67,5 +66,4 @@ OpenDir::size() { return entries.size(); } -} // namespace filemap -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::filemap \ No newline at end of file diff --git a/src/client/open_file_map.cpp b/src/client/open_file_map.cpp index 06cc770a9..34242ec2b 100644 --- a/src/client/open_file_map.cpp +++ b/src/client/open_file_map.cpp @@ -39,8 +39,7 @@ extern "C" { using namespace std; -namespace gkfs { -namespace filemap { +namespace gkfs::filemap { OpenFile::OpenFile(const string& path, const int flags, FileType type) : type_(type), path_(path) { @@ -240,5 +239,4 @@ OpenFileMap::get_fd_idx() { return fd_idx; } -} // namespace filemap -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::filemap \ No newline at end of file diff --git a/src/client/path.cpp b/src/client/path.cpp index 3b2164b59..d0d437ee3 100644 --- a/src/client/path.cpp +++ b/src/client/path.cpp @@ -46,8 +46,7 @@ extern "C" { using namespace std; -namespace gkfs { -namespace path { +namespace gkfs::path { static const string excluded_paths[2] = {"sys/", "proc/"}; @@ -325,5 +324,4 @@ set_cwd(const string& path, bool internal) { CTX->cwd(path); } -} // namespace path -} // namespace gkfs \ No newline at end of file +} // namespace gkfs::path \ No newline at end of file diff --git a/src/client/rpc/forward_management.cpp b/src/client/rpc/forward_management.cpp index 7d39435ce..ee7530891 100644 --- a/src/client/rpc/forward_management.cpp +++ b/src/client/rpc/forward_management.cpp @@ -32,8 +32,7 @@ #include #include -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { /** * Gets fs configuration information from the running daemon and transfers it to @@ -76,5 +75,4 @@ forward_get_fs_config() { return true; } -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc diff --git a/src/client/rpc/forward_metadata.cpp b/src/client/rpc/forward_metadata.cpp index 1cb51ab86..f23a6cd9f 100644 --- a/src/client/rpc/forward_metadata.cpp +++ b/src/client/rpc/forward_metadata.cpp @@ -40,8 +40,7 @@ using namespace std; -namespace gkfs { -namespace rpc { +namespace gkfs::rpc { /* * This file includes all metadata RPC calls. @@ -723,5 +722,4 @@ forward_mk_symlink(const std::string& path, const std::string& target_path) { #endif -} // namespace rpc -} // namespace gkfs +} // namespace gkfs::rpc diff --git a/src/daemon/backend/metadata/merge.cpp b/src/daemon/backend/metadata/merge.cpp index 75bcfceec..68d29aa18 100644 --- a/src/daemon/backend/metadata/merge.cpp +++ b/src/daemon/backend/metadata/merge.cpp @@ -31,8 +31,7 @@ using namespace std; -namespace gkfs { -namespace metadata { +namespace gkfs::metadata { string MergeOperand::serialize_id() const { @@ -207,5 +206,4 @@ MetadataMergeOperator::AllowSingleOperand() const { return true; } -} // namespace metadata -} // namespace gkfs +} // namespace gkfs::metadata diff --git a/src/daemon/ops/data.cpp b/src/daemon/ops/data.cpp index ab30f542d..c8c8c4dea 100644 --- a/src/daemon/ops/data.cpp +++ b/src/daemon/ops/data.cpp @@ -37,8 +37,7 @@ extern "C" { using namespace std; -namespace gkfs { -namespace data { +namespace gkfs::data { /* ------------------------------------------------------------------------ * -------------------------- TRUNCATE ------------------------------------ @@ -469,5 +468,4 @@ ChunkReadOperation::wait_for_tasks_and_push_back(const bulk_args& args) { return make_pair(io_err, total_read); } -} // namespace data -} // namespace gkfs +} // namespace gkfs::data -- GitLab