diff --git a/include/drives/winfsp/winfsp_drive.hpp b/include/drives/winfsp/winfsp_drive.hpp index 38c8a419..2e1e4d6e 100644 --- a/include/drives/winfsp/winfsp_drive.hpp +++ b/include/drives/winfsp/winfsp_drive.hpp @@ -193,9 +193,10 @@ public: void shutdown(); - static void display_options(std::vector args) {} + static void display_options(std::vector /* args */) {} - static void display_version_information(std::vector args) {} + static void + display_version_information(std::vector /* args */) {} }; } // namespace repertory diff --git a/src/drives/winfsp/remotewinfsp/remote_server.cpp b/src/drives/winfsp/remotewinfsp/remote_server.cpp index 603c130c..7d10b251 100644 --- a/src/drives/winfsp/remotewinfsp/remote_server.cpp +++ b/src/drives/winfsp/remotewinfsp/remote_server.cpp @@ -90,7 +90,7 @@ void remote_server::populate_stat(const char *path, bool directory, st.st_birthtimespec = utils::time64_to_unix_time(st1.st_ctime); st.st_ctimespec = utils::time64_to_unix_time(st1.st_ctime); st.st_mtimespec = utils::time64_to_unix_time(st1.st_mtime); - st.st_size = st1.st_size; + st.st_size = static_cast(st1.st_size); st.st_mode = st1.st_mode; } @@ -221,7 +221,7 @@ auto remote_server::fuse_ftruncate(const char *path, if (os_handle != INVALID_HANDLE_VALUE) { errno = EFAULT; FILE_END_OF_FILE_INFO fi{}; - fi.EndOfFile.QuadPart = size; + fi.EndOfFile.QuadPart = static_cast(size); if (::SetFileInformationByHandle(os_handle, FileEndOfFileInfo, &fi, sizeof(FILE_END_OF_FILE_INFO))) { res = 0; @@ -341,7 +341,7 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode, const auto res = _sopen_s(&fd, file_path.c_str(), open_flags, _SH_DENYNO, perms); if (res == 0) { - handle = fd; + handle = static_cast(fd); ret = 0; set_compat_open_info(handle, file_path); } else { @@ -370,7 +370,7 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags, int fd = -1; res = _sopen_s(&fd, file_path.c_str(), open_flags, _SH_DENYNO, 0); if (res == 0) { - handle = fd; + handle = static_cast(fd); set_compat_open_info(handle, file_path); } else { res = -1; @@ -634,7 +634,7 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize, st.f_ffree = st.f_favail = st.f_files - drive_.get_total_item_count(); strncpy(&st.f_mntfromname[0u], (utils::create_volume_label(config_.get_provider_type())).c_str(), - 1024); + sizeof(st.f_mntfromname) - 1U); RAISE_REMOTE_WINFSP_SERVER_EVENT(__FUNCTION__, file_path, 0); return 0; @@ -656,11 +656,11 @@ auto remote_server::fuse_truncate(const char *path, const auto os_handle = ::CreateFileW( unicode_file_path.c_str(), FILE_GENERIC_READ | FILE_GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, - OPEN_EXISTING, flags_and_attributes, nullptr); + OPEN_EXISTING, static_cast(flags_and_attributes), nullptr); if (os_handle != INVALID_HANDLE_VALUE) { errno = EFAULT; FILE_END_OF_FILE_INFO fi{}; - fi.EndOfFile.QuadPart = size; + fi.EndOfFile.QuadPart = static_cast(size); if (::SetFileInformationByHandle(os_handle, FileEndOfFileInfo, &fi, sizeof(FILE_END_OF_FILE_INFO))) { res = 0; @@ -696,10 +696,10 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, (::PathIsDirectoryW(unicode_file_path.c_str()) ? FILE_ATTRIBUTE_DIRECTORY | FILE_FLAG_POSIX_SEMANTICS : 0); - const auto os_handle = - ::CreateFileW(unicode_file_path.c_str(), FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - nullptr, OPEN_EXISTING, flags_and_attributes, nullptr); + const auto os_handle = ::CreateFileW( + unicode_file_path.c_str(), FILE_WRITE_ATTRIBUTES, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, + OPEN_EXISTING, static_cast(flags_and_attributes), nullptr); if (os_handle != INVALID_HANDLE_VALUE) { FILETIME access_time{}; FILETIME write_time{}; @@ -708,7 +708,8 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, if (not tv[0u] || (op0 == UTIME_NOW)) { const auto now = utils::get_file_time_now(); - access_time.dwHighDateTime = ((now >> 32u) & 0xFFFFFFFF); + access_time.dwHighDateTime = + static_cast((now >> 32u) & 0xFFFFFFFF); access_time.dwLowDateTime = now & 0xFFFFFFFF; access_time_ptr = &access_time; } else if (op0 != UTIME_OMIT) { @@ -718,7 +719,7 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, if (not tv[1] || (op1 == UTIME_NOW)) { const auto now = utils::get_file_time_now(); - write_time.dwHighDateTime = ((now >> 32u) & 0xFFFFFFFF); + write_time.dwHighDateTime = static_cast((now >> 32u) & 0xFFFFFFFF); write_time.dwLowDateTime = now & 0xFFFFFFFF; write_time_ptr = &write_time; } else if (op1 != UTIME_OMIT) { @@ -865,17 +866,17 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, create_flags |= FILE_FLAG_POSIX_SEMANTICS; attributes |= FILE_ATTRIBUTE_DIRECTORY; } else { - attributes &= ~FILE_ATTRIBUTE_DIRECTORY; + attributes &= static_cast(~FILE_ATTRIBUTE_DIRECTORY); } if (not attributes) { attributes = FILE_ATTRIBUTE_NORMAL; } - const auto handle = - ::CreateFileW(file_path.c_str(), granted_access, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - nullptr, CREATE_NEW, create_flags | attributes, nullptr); + const auto handle = ::CreateFileW( + file_path.c_str(), granted_access, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, + CREATE_NEW, static_cast(create_flags) | attributes, nullptr); if (handle != INVALID_HANDLE_VALUE) { *file_desc = reinterpret_cast(handle); normalized_name = utils::string::to_utf8(file_name); @@ -995,10 +996,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, create_flags |= FILE_FLAG_DELETE_ON_CLOSE; } - const auto handle = - ::CreateFileW(file_path.c_str(), granted_access, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - nullptr, OPEN_EXISTING, create_flags, nullptr); + const auto handle = ::CreateFileW( + file_path.c_str(), granted_access, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, + OPEN_EXISTING, static_cast(create_flags), nullptr); if (handle != INVALID_HANDLE_VALUE) { *file_desc = reinterpret_cast(handle); normalized_name = utils::string::to_utf8(file_name); @@ -1043,7 +1044,8 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, } else { FILE_BASIC_INFO basic_info{}; basic_info.FileAttributes = - attributes | (tag_info.FileAttributes & ~(FILE_ATTRIBUTE_NORMAL)); + attributes | (tag_info.FileAttributes & + static_cast(~FILE_ATTRIBUTE_NORMAL)); if ((basic_info.FileAttributes != tag_info.FileAttributes)) { if (not ::SetFileInformationByHandle(handle, FileBasicInfo, &basic_info, @@ -1159,10 +1161,11 @@ auto remote_server::winfsp_set_basic_info( FILE_BASIC_INFO basic_info{}; basic_info.FileAttributes = attributes; - basic_info.CreationTime.QuadPart = creation_time; - basic_info.LastAccessTime.QuadPart = last_access_time; - basic_info.LastWriteTime.QuadPart = last_write_time; - basic_info.ChangeTime.QuadPart = change_time; + basic_info.CreationTime.QuadPart = static_cast(creation_time); + basic_info.LastAccessTime.QuadPart = + static_cast(last_access_time); + basic_info.LastWriteTime.QuadPart = static_cast(last_write_time); + basic_info.ChangeTime.QuadPart = static_cast(change_time); ret = ::SetFileInformationByHandle(handle, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)) ? populate_file_info( @@ -1183,7 +1186,7 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, if (ret == STATUS_SUCCESS) { if (set_allocation_size) { FILE_ALLOCATION_INFO allocation_info{}; - allocation_info.AllocationSize.QuadPart = new_size; + allocation_info.AllocationSize.QuadPart = static_cast(new_size); if (not ::SetFileInformationByHandle(handle, FileAllocationInfo, &allocation_info, sizeof(FILE_ALLOCATION_INFO))) { @@ -1191,7 +1194,7 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, } } else { FILE_END_OF_FILE_INFO end_of_file_info{}; - end_of_file_info.EndOfFile.QuadPart = new_size; + end_of_file_info.EndOfFile.QuadPart = static_cast(new_size); if (not ::SetFileInformationByHandle(handle, FileEndOfFileInfo, &end_of_file_info, sizeof(FILE_END_OF_FILE_INFO))) { diff --git a/src/drives/winfsp/winfsp_drive.cpp b/src/drives/winfsp/winfsp_drive.cpp index 0ecf49ad..b7ecb8bd 100644 --- a/src/drives/winfsp/winfsp_drive.cpp +++ b/src/drives/winfsp/winfsp_drive.cpp @@ -325,8 +325,8 @@ auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, std::shared_ptr f; if (fm_->get_open_file(handle, false, f)) { api_path = f->get_api_path(); - error = f->native_operation([&](native_handle handle) { - if (not ::FlushFileBuffers(handle)) { + error = f->native_operation([&](native_handle op_handle) { + if (not ::FlushFileBuffers(op_handle)) { return api_error::os_error; }