diff --git a/src/drives/fuse/fuse_drive.cpp b/src/drives/fuse/fuse_drive.cpp index ce36d15b..31951da3 100644 --- a/src/drives/fuse/fuse_drive.cpp +++ b/src/drives/fuse/fuse_drive.cpp @@ -912,7 +912,7 @@ auto fuse_drive::listxattr_impl(std::string api_path, char *buffer, size_t size, res = api_error::xattr_buffer_small; } - required_size += attribute_name_size; + required_size += static_cast(attribute_name_size); #ifdef __APPLE__ } #endif diff --git a/src/drives/fuse/remotefuse/remote_fuse_drive.cpp b/src/drives/fuse/remotefuse/remote_fuse_drive.cpp index b6d509ca..3c0adeea 100644 --- a/src/drives/fuse/remotefuse/remote_fuse_drive.cpp +++ b/src/drives/fuse/remotefuse/remote_fuse_drive.cpp @@ -60,8 +60,8 @@ auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode, auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error { #endif - return utils::to_api_error( - remote_instance_->fuse_chmod(api_path.c_str(), mode)); + return utils::to_api_error(remote_instance_->fuse_chmod( + api_path.c_str(), static_cast(mode))); } #if FUSE_USE_VERSION >= 30 @@ -79,7 +79,9 @@ auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) auto remote_fuse_drive::create_impl(std::string api_path, mode_t mode, struct fuse_file_info *fi) -> api_error { return utils::to_api_error(remote_instance_->fuse_create( - api_path.c_str(), mode, remote::create_open_flags(fi->flags), fi->fh)); + api_path.c_str(), static_cast(mode), + remote::create_open_flags(static_cast(fi->flags)), + fi->fh)); } void remote_fuse_drive::destroy_impl(void * /*ptr*/) { @@ -248,8 +250,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * { auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode) -> api_error { - return utils::to_api_error( - remote_instance_->fuse_mkdir(api_path.c_str(), mode)); + return utils::to_api_error(remote_instance_->fuse_mkdir( + api_path.c_str(), static_cast(mode))); } void remote_fuse_drive::notify_fuse_main_exit(int &ret) { diff --git a/src/drives/fuse/remotefuse/remote_server.cpp b/src/drives/fuse/remotefuse/remote_server.cpp index 120ebd91..cbb37c45 100644 --- a/src/drives/fuse/remotefuse/remote_server.cpp +++ b/src/drives/fuse/remotefuse/remote_server.cpp @@ -166,12 +166,12 @@ void remote_server::populate_stat(const struct stat64 &st1, remote::stat &st) { st.st_mtimespec = st1.st_mtim.tv_nsec + (st1.st_mtim.tv_sec * NANOS_PER_SECOND); #endif - st.st_blksize = st1.st_blksize; - st.st_blocks = st1.st_blocks; + st.st_blksize = static_cast(st1.st_blksize); + st.st_blocks = static_cast(st1.st_blocks); st.st_gid = st1.st_gid; - st.st_mode = st1.st_mode; - st.st_nlink = st1.st_nlink; - st.st_size = st1.st_size; + st.st_mode = static_cast(st1.st_mode); + st.st_nlink = static_cast(st1.st_nlink); + st.st_size = static_cast(st1.st_size); st.st_uid = st1.st_uid; } @@ -269,13 +269,12 @@ ConstructPath(path); auto ret = HasOpenFileInfo(handle, -EBADF); if (ret == 0) { fstore.fst_offset = offset; fstore.fst_length = length; - const auto res = fcntl(static_cast(handle), F_PREALLOCATE, &fstore); - ret = ((res < 0) ? -errno : 0); + const auto res = fcntl(static_cast(handle), F_PREALLOCATE, +&fstore); ret = ((res < 0) ? -errno : 0); } #else - const auto res = fallocate(static_cast(handle), mode, offset, length); - ret = ((res < 0) ? -errno : 0); -#endif + const auto res = fallocate(static_cast(handle), mode, offset, +length); ret = ((res < 0) ? -errno : 0); #endif } RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, file_path, ret); @@ -289,11 +288,11 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &st, const auto file_path = construct_path(path); memset(&st, 0, sizeof(remote::stat)); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { directory = utils::file::is_directory(file_path); struct stat64 st1 {}; - if ((res = fstat64(static_cast(handle), &st1)) == 0) { + if ((res = fstat64(static_cast(handle), &st1)) == 0) { populate_stat(st1, st); } } @@ -314,12 +313,12 @@ auto remote_server::fuse_fsetattr_x(const char *path, if (SETATTR_WANTS_MODE(&attr)) { res = (handle == static_cast(REPERTORY_INVALID_HANDLE)) ? chmod(file_path.c_str(), attr.mode) - : fchmod(handle, attr.mode); + : fchmod(static_cast(handle), attr.mode); } if (res >= 0) { - uid_t uid = -1; - gid_t gid = -1; + auto uid = static_cast(-1); + auto gid = static_cast(-1); if (SETATTR_WANTS_UID(&attr)) { uid = attr.uid; } @@ -338,7 +337,7 @@ auto remote_server::fuse_fsetattr_x(const char *path, if (SETATTR_WANTS_SIZE(&attr)) { res = (handle == static_cast(REPERTORY_INVALID_HANDLE)) ? truncate(file_path.c_str(), attr.size) - : ftruncate(handle, attr.size); + : ftruncate(static_cast(handle), attr.size); } } @@ -397,14 +396,14 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync, -> packet::error_type { const auto file_path = construct_path(path); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { #ifdef __APPLE__ - res = datasync ? fcntl(static_cast(handle), F_FULLFSYNC) - : fsync(static_cast(handle)); + res = datasync ? fcntl(static_cast(handle), F_FULLFSYNC) + : fsync(static_cast(handle)); #else - res = datasync ? fdatasync(static_cast(handle)) - : fsync(static_cast(handle)); + res = datasync ? fdatasync(static_cast(handle)) + : fsync(static_cast(handle)); #endif } @@ -419,9 +418,9 @@ auto remote_server::fuse_ftruncate(const char *path, -> packet::error_type { const auto file_path = construct_path(path); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { - res = ftruncate(static_cast(handle), size); + res = ftruncate(static_cast(handle), size); } auto ret = ((res < 0) ? -errno : 0); @@ -472,7 +471,7 @@ utils::path::get_parent_api_path(api_path); res = -ENODATA; if (directoryItem.MetaMap.find(name) != directoryItem.MetaMap.end()) { const auto data = macaron::Base64::Decode(directoryItem.MetaMap[name]); res = -static_cast(data.size()); if (size) { res = -ERANGE; if (size >= +static_cast(data.size()); if (size) { res = -ERANGE; if (size >= data.size()) { memcpy(value, &data[0], data.size()); res = 0; } } @@ -601,10 +600,11 @@ auto remote_server::fuse_read(const char *path, char *buffer, -> packet::error_type { const auto file_path = construct_path(path); auto &b = *reinterpret_cast(buffer); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { b.resize(read_size); - res = pread64(static_cast(handle), &b[0], read_size, read_offset); + res = pread64(static_cast(handle), &b[0], read_size, + read_offset); } auto ret = ((res < 0) ? -errno : res); @@ -655,10 +655,10 @@ auto remote_server::fuse_release(const char *path, packet::error_type ret = 0; const auto file_path = construct_path(path); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { - res = close(static_cast(handle)); - remove_open_info(handle); + res = close(static_cast(handle)); + remove_open_info(static_cast(handle)); } ret = ((res < 0) ? -errno : 0); @@ -890,9 +890,10 @@ auto remote_server::fuse_write(const char *path, const char *buffer, const remote::file_handle &handle) -> packet::error_type { const auto file_path = construct_path(path); - auto res = has_open_info(handle, EBADF); + auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { - res = pwrite64(static_cast(handle), buffer, write_size, write_offset); + res = pwrite64(static_cast(handle), buffer, write_size, + write_offset); } auto ret = ((res < 0) ? -errno : res); @@ -994,10 +995,11 @@ auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_close(PVOID file_desc) -> packet::error_type { std::string file_path; const auto handle = reinterpret_cast(file_desc); - if (has_open_info(handle, STATUS_INVALID_HANDLE) == STATUS_SUCCESS) { - file_path = get_open_file_path(handle); - close(handle); - remove_open_info(handle); + if (has_open_info(static_cast(handle), + STATUS_INVALID_HANDLE) == STATUS_SUCCESS) { + file_path = get_open_file_path(static_cast(handle)); + close(static_cast(handle)); + remove_open_info(static_cast(handle)); } RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, file_path, STATUS_SUCCESS); @@ -1056,15 +1058,19 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) -> packet::error_type { const auto handle = reinterpret_cast(file_desc); - auto ret = has_open_info(handle, STATUS_INVALID_HANDLE); + auto ret = + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); if (ret == STATUS_SUCCESS) { - ret = (fsync(static_cast(handle)) < 0) + ret = (fsync(static_cast(handle)) < 0) ? utils::unix_error_to_windows(errno) - : populate_file_info( - construct_api_path(get_open_file_path(handle)), *file_info); + : populate_file_info(construct_api_path(get_open_file_path( + static_cast(handle))), + *file_info); } - RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret); + RAISE_REMOTE_FUSE_SERVER_EVENT( + __FUNCTION__, get_open_file_path(static_cast(handle)), + ret); return ret; } @@ -1072,13 +1078,17 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info) -> packet::error_type { const auto handle = reinterpret_cast(file_desc); - auto ret = has_open_info(handle, STATUS_INVALID_HANDLE); + auto ret = + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); if (ret == STATUS_SUCCESS) { - ret = populate_file_info(construct_api_path(get_open_file_path(handle)), + ret = populate_file_info(construct_api_path(get_open_file_path( + static_cast(handle))), *file_info); } - RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret); + RAISE_REMOTE_FUSE_SERVER_EVENT( + __FUNCTION__, get_open_file_path(static_cast(handle)), + ret); return ret; } @@ -1163,10 +1173,12 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, remote::file_info *file_info) -> packet::error_type { const auto handle = reinterpret_cast(file_desc); - auto ret = has_open_info(handle, STATUS_INVALID_HANDLE); + auto ret = + has_open_info(static_cast(handle), STATUS_INVALID_HANDLE); if (ret == STATUS_SUCCESS) { - const auto api_path = construct_api_path(get_open_file_path(handle)); - const auto res = ftruncate(handle, 0); + const auto api_path = construct_api_path( + get_open_file_path(static_cast(handle))); + const auto res = ftruncate(static_cast(handle), 0); if (res >= 0) { auto set_attributes = false; if (replace_attributes) {