diff --git a/repertory/librepertory/include/common.hpp b/repertory/librepertory/include/common.hpp index 41aad94a..b736f585 100644 --- a/repertory/librepertory/include/common.hpp +++ b/repertory/librepertory/include/common.hpp @@ -181,6 +181,7 @@ inline constexpr const auto NANOS_PER_SECOND = 1000000000L; using BOOLEAN = std::uint8_t; using DWORD = std::uint32_t; using HANDLE = void *; +using NTSTATUS = std::uint32_t; using PUINT32 = std::uint32_t *; using PVOID = void *; using PWSTR = wchar_t *; @@ -231,7 +232,7 @@ using WCHAR = wchar_t; #define MAX_PATH 260 #define STATUS_SUCCESS \ - std::uint32_t { 0 } + std::uint32_t { 0U } #define STATUS_ACCESS_DENIED \ std::uint32_t { 0xC0000022L } #define STATUS_DEVICE_BUSY \ @@ -263,14 +264,14 @@ using WCHAR = wchar_t; #define STATUS_OBJECT_NAME_EXISTS \ std::uint32_t { 0x40000000L } #define STATUS_OBJECT_NAME_NOT_FOUND \ - std::int32_t { 0xC0000034L } + std::uint32_t { 0xC0000034L } #define STATUS_OBJECT_PATH_INVALID \ std::uint32_t { 0xC0000039L } #define STATUS_UNEXPECTED_IO_ERROR \ std::uint32_t { 0xC00000E9L } #define CONVERT_STATUS_NOT_IMPLEMENTED(e) \ - ((std::uint32_t{e} == STATUS_NOT_IMPLEMENTED) ? -ENOTSUP : e) + ((std::uint32_t(e) == STATUS_NOT_IMPLEMENTED) ? -ENOTSUP : e) namespace Fsp::FileSystemBase { enum { diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp index 37798603..7b341607 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_server.hpp @@ -226,7 +226,7 @@ public: [[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/, PVOID *& /*ptr*/) -> packet::error_type override { - return STATUS_INVALID_HANDLE; + return static_cast(STATUS_INVALID_HANDLE); } [[nodiscard]] auto json_create_directory_snapshot( diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index 87ebb885..b9188ea1 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -59,7 +59,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -74,7 +74,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -97,7 +97,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -109,7 +109,7 @@ public: [this](std::uint32_t, const std::string &client_id, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); std::wstring file_name; DECODE_OR_RETURN(request, file_name); @@ -156,7 +156,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -174,7 +174,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -191,7 +191,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); std::wstring file_name; DECODE_OR_RETURN(request, file_name); @@ -218,30 +218,30 @@ public: return ret; }}); - handler_lookup_.insert({"::winfsp_get_volume_info", - [this](std::uint32_t, const std::string &, - std::uint64_t, const std::string &, packet *, - packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + handler_lookup_.insert( + {"::winfsp_get_volume_info", + [this](std::uint32_t, const std::string &, std::uint64_t, + const std::string &, packet *, + packet &response) -> packet::error_type { + auto ret = static_cast(STATUS_SUCCESS); - UINT64 total_size{}; - UINT64 free_size{}; - std::string volume_label; - if ((ret = this->winfsp_get_volume_info( - total_size, free_size, volume_label)) == - STATUS_SUCCESS) { - response.encode(total_size); - response.encode(free_size); - response.encode(volume_label); - } - return ret; - }}); + UINT64 total_size{}; + UINT64 free_size{}; + std::string volume_label; + if ((ret = this->winfsp_get_volume_info( + total_size, free_size, volume_label)) == STATUS_SUCCESS) { + response.encode(total_size); + response.encode(free_size); + response.encode(volume_label); + } + return ret; + }}); handler_lookup_.insert( {"::winfsp_mounted", [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); std::string version; DECODE_OR_RETURN(request, version); @@ -257,7 +257,7 @@ public: [this](std::uint32_t, const std::string &client_id, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); std::wstring file_name; DECODE_OR_RETURN(request, file_name); @@ -295,7 +295,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -323,7 +323,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -351,7 +351,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -378,7 +378,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -401,7 +401,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -435,7 +435,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); @@ -459,7 +459,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); std::wstring location; DECODE_OR_RETURN(request, location); @@ -471,7 +471,7 @@ public: [this](std::uint32_t, const std::string &, std::uint64_t, const std::string &, packet *request, packet &response) -> packet::error_type { - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); HANDLE file_desc{}; DECODE_OR_RETURN(request, file_desc); diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index a3957aa0..a3bcc03e 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -107,7 +107,7 @@ auto remote_server::populate_file_info(const std::string &api_path, return STATUS_SUCCESS; } - return STATUS_OBJECT_NAME_NOT_FOUND; + return static_cast(STATUS_OBJECT_NAME_NOT_FOUND); } void remote_server::populate_file_info(const std::string &api_path, @@ -992,19 +992,19 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, const auto relative_path = utils::string::to_utf8(file_name); const auto file_path = construct_path(relative_path); - auto ret = + auto ret = static_cast( has_open_info(static_cast( reinterpret_cast(file_desc)), - STATUS_INVALID_HANDLE); + STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { ret = utils::file::is_directory(file_path) ? (drive_.get_directory_item_count( utils::path::create_api_path(relative_path)) - ? STATUS_DIRECTORY_NOT_EMPTY + ? static_cast(STATUS_DIRECTORY_NOT_EMPTY) : STATUS_SUCCESS) : (drive_.is_processing(utils::path::create_api_path(relative_path)) - ? STATUS_DEVICE_BUSY + ? static_cast(STATUS_DEVICE_BUSY) : STATUS_SUCCESS); } @@ -1144,8 +1144,8 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { ret = (fsync(static_cast(handle)) < 0) ? utils::unix_error_to_windows(errno) @@ -1165,8 +1165,8 @@ auto remote_server::winfsp_get_file_info( constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { ret = populate_file_info(construct_api_path(get_open_file_path( static_cast(handle))), @@ -1185,7 +1185,7 @@ auto remote_server::winfsp_get_security_by_name( std::wstring & /*str_descriptor*/) -> packet::error_type { constexpr const auto *function_name = static_cast(__FUNCTION__); - auto ret = STATUS_SUCCESS; + auto ret = static_cast(STATUS_SUCCESS); const auto file_path = construct_path(file_name); if (utils::file::is_file(file_path) || (utils::file::is_directory(file_path))) { @@ -1197,7 +1197,7 @@ auto remote_server::winfsp_get_security_by_name( } } } else { - ret = STATUS_OBJECT_NAME_NOT_FOUND; + ret = static_cast(STATUS_OBJECT_NAME_NOT_FOUND); } RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, construct_path(file_name), ret); @@ -1268,8 +1268,8 @@ auto remote_server::winfsp_overwrite( constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto api_path = construct_api_path( get_open_file_path(static_cast(handle))); @@ -1325,8 +1325,8 @@ auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, *bytes_transferred = 0; const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto res = pread64(static_cast(handle), buffer, length, static_cast(offset)); @@ -1351,8 +1351,8 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, item_list.clear(); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto api_path = construct_api_path( get_open_file_path(static_cast(handle))); @@ -1413,8 +1413,8 @@ auto remote_server::winfsp_set_basic_info( constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto file_path = get_open_file_path(static_cast(handle)); @@ -1476,8 +1476,8 @@ auto remote_server::winfsp_set_file_size( constexpr const auto *function_name = static_cast(__FUNCTION__); const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto res = set_allocation_size == 0U ? ftruncate(static_cast(handle), @@ -1514,8 +1514,8 @@ auto remote_server::winfsp_write( *bytes_transferred = 0; const auto handle = reinterpret_cast(file_desc); - auto ret = - has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); + auto ret = static_cast( + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE)); if (ret == STATUS_SUCCESS) { const auto api_path = construct_api_path( get_open_file_path(static_cast(handle)));