2 Commits

Author SHA1 Message Date
c0e720498d Address compiler warnings #10
All checks were successful
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
2023-10-30 11:49:56 -05:00
383c3b4be6 Address compiler warnings #10 [Wconversion] 2023-10-30 11:41:45 -05:00
3 changed files with 124 additions and 80 deletions

View File

@ -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<int>(attribute_name_size);
#ifdef __APPLE__
}
#endif

View File

@ -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<remote::file_mode>(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<remote::file_mode>(mode),
remote::create_open_flags(static_cast<std::uint32_t>(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<remote::file_mode>(mode)));
}
void remote_fuse_drive::notify_fuse_main_exit(int &ret) {

View File

@ -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<remote::block_size>(st1.st_blksize);
st.st_blocks = static_cast<remote::block_count>(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<remote::file_mode>(st1.st_mode);
st.st_nlink = static_cast<remote::file_nlink>(st1.st_nlink);
st.st_size = static_cast<remote::file_size>(st1.st_size);
st.st_uid = st1.st_uid;
}
@ -227,9 +227,10 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
-> packet::error_type {
const auto file_path = construct_path(path);
const auto res =
open(file_path.c_str(), remote::create_os_open_flags(flags), mode);
open(file_path.c_str(),
static_cast<int>(remote::create_os_open_flags(flags)), mode);
if (res >= 0) {
handle = res;
handle = static_cast<remote::file_handle>(res);
set_open_info(res, open_info{0, "", nullptr, file_path});
}
@ -269,13 +270,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<int>(handle), F_PREALLOCATE, &fstore);
ret = ((res < 0) ? -errno : 0);
const auto res = fcntl(static_cast<native_handle>(handle), F_PREALLOCATE,
&fstore); ret = ((res < 0) ? -errno : 0);
}
#else
const auto res = fallocate(static_cast<int>(handle), mode, offset, length);
ret = ((res < 0) ? -errno : 0);
#endif
const auto res = fallocate(static_cast<native_handle>(handle), mode, offset,
length); ret = ((res < 0) ? -errno : 0); #endif
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, file_path, ret);
@ -289,11 +289,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<native_handle>(handle), EBADF);
if (res == 0) {
directory = utils::file::is_directory(file_path);
struct stat64 st1 {};
if ((res = fstat64(static_cast<int>(handle), &st1)) == 0) {
if ((res = fstat64(static_cast<native_handle>(handle), &st1)) == 0) {
populate_stat(st1, st);
}
}
@ -314,12 +314,12 @@ auto remote_server::fuse_fsetattr_x(const char *path,
if (SETATTR_WANTS_MODE(&attr)) {
res = (handle == static_cast<std::uint64_t>(REPERTORY_INVALID_HANDLE))
? chmod(file_path.c_str(), attr.mode)
: fchmod(handle, attr.mode);
: fchmod(static_cast<native_handle>(handle), attr.mode);
}
if (res >= 0) {
uid_t uid = -1;
gid_t gid = -1;
auto uid = static_cast<uid_t>(-1);
auto gid = static_cast<gid_t>(-1);
if (SETATTR_WANTS_UID(&attr)) {
uid = attr.uid;
}
@ -338,7 +338,7 @@ auto remote_server::fuse_fsetattr_x(const char *path,
if (SETATTR_WANTS_SIZE(&attr)) {
res = (handle == static_cast<std::uint64_t>(REPERTORY_INVALID_HANDLE))
? truncate(file_path.c_str(), attr.size)
: ftruncate(handle, attr.size);
: ftruncate(static_cast<native_handle>(handle), attr.size);
}
}
@ -397,14 +397,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<native_handle>(handle), EBADF);
if (res == 0) {
#ifdef __APPLE__
res = datasync ? fcntl(static_cast<int>(handle), F_FULLFSYNC)
: fsync(static_cast<int>(handle));
res = datasync ? fcntl(static_cast<native_handle>(handle), F_FULLFSYNC)
: fsync(static_cast<native_handle>(handle));
#else
res = datasync ? fdatasync(static_cast<int>(handle))
: fsync(static_cast<int>(handle));
res = datasync ? fdatasync(static_cast<native_handle>(handle))
: fsync(static_cast<native_handle>(handle));
#endif
}
@ -419,9 +419,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<native_handle>(handle), EBADF);
if (res == 0) {
res = ftruncate(static_cast<int>(handle), size);
res = ftruncate(static_cast<native_handle>(handle), size);
}
auto ret = ((res < 0) ? -errno : 0);
@ -472,7 +472,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<int>(data.size()); if (size) { res = -ERANGE; if (size >=
static_cast<native_handle>(data.size()); if (size) { res = -ERANGE; if (size >=
data.size()) { memcpy(value, &data[0], data.size()); res = 0;
}
}
@ -561,9 +561,10 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle)
-> packet::error_type {
const auto file_path = construct_path(path);
const auto res = open(file_path.c_str(), remote::create_os_open_flags(flags));
const auto res = open(file_path.c_str(),
static_cast<int>(remote::create_os_open_flags(flags)));
if (res >= 0) {
handle = res;
handle = static_cast<remote::file_handle>(res);
set_open_info(res, open_info{0, "", nullptr, file_path});
}
auto ret = ((res < 0) ? -errno : 0);
@ -601,10 +602,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<data_buffer *>(buffer);
auto res = has_open_info(handle, EBADF);
auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
if (res == 0) {
b.resize(read_size);
res = pread64(static_cast<int>(handle), &b[0], read_size, read_offset);
res = pread64(static_cast<native_handle>(handle), &b[0], read_size,
read_offset);
}
auto ret = ((res < 0) ? -errno : res);
@ -655,10 +657,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<native_handle>(handle), EBADF);
if (res == 0) {
res = close(static_cast<int>(handle));
remove_open_info(handle);
res = close(static_cast<native_handle>(handle));
remove_open_info(static_cast<native_handle>(handle));
}
ret = ((res < 0) ? -errno : 0);
@ -890,9 +892,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<native_handle>(handle), EBADF);
if (res == 0) {
res = pwrite64(static_cast<int>(handle), buffer, write_size, write_offset);
res = pwrite64(static_cast<native_handle>(handle), buffer, write_size,
write_offset);
}
auto ret = ((res < 0) ? -errno : res);
@ -916,7 +919,9 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type {
const auto relative_path = utils::string::to_utf8(file_name);
const auto file_path = construct_path(relative_path);
auto ret = has_open_info(reinterpret_cast<remote::file_handle>(file_desc),
auto ret =
has_open_info(static_cast<native_handle>(
reinterpret_cast<remote::file_handle>(file_desc)),
STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
ret =
@ -994,10 +999,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<remote::file_handle>(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<native_handle>(handle),
STATUS_INVALID_HANDLE) == STATUS_SUCCESS) {
file_path = get_open_file_path(static_cast<native_handle>(handle));
close(static_cast<native_handle>(handle));
remove_open_info(static_cast<native_handle>(handle));
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, file_path, STATUS_SUCCESS);
@ -1056,15 +1062,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<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
ret = (fsync(static_cast<int>(handle)) < 0)
ret = (fsync(static_cast<native_handle>(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<native_handle>(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<native_handle>(handle)),
ret);
return ret;
}
@ -1072,13 +1082,17 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info)
-> packet::error_type {
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(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<native_handle>(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<native_handle>(handle)),
ret);
return ret;
}
@ -1163,10 +1177,12 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
remote::file_info *file_info)
-> packet::error_type {
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(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<native_handle>(handle)));
const auto res = ftruncate(static_cast<native_handle>(handle), 0);
if (res >= 0) {
auto set_attributes = false;
if (replace_attributes) {
@ -1195,14 +1211,17 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
drive_.set_item_meta(api_path, META_ATTRIBUTES,
std::to_string(attributes));
}
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<native_handle>(handle))),
*file_info);
} else {
ret = utils::unix_error_to_windows(errno);
}
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret);
RAISE_REMOTE_FUSE_SERVER_EVENT(
__FUNCTION__, get_open_file_path(static_cast<native_handle>(handle)),
ret);
return ret;
}
@ -1212,17 +1231,20 @@ auto remote_server::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
*bytes_transferred = 0;
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
const auto res = pread64(handle, buffer, length, offset);
if (res >= 0) {
*bytes_transferred = res;
*bytes_transferred = static_cast<UINT32>(res);
} else {
ret = utils::unix_error_to_windows(errno);
}
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret);
RAISE_REMOTE_FUSE_SERVER_EVENT(
__FUNCTION__, get_open_file_path(static_cast<native_handle>(handle)),
ret);
return ret;
}
@ -1232,9 +1254,11 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
item_list.clear();
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
const auto api_path = construct_api_path(get_open_file_path(handle));
const auto api_path = construct_api_path(
get_open_file_path(static_cast<native_handle>(handle)));
auto list = drive_.get_directory_items(api_path);
directory_iterator iterator(std::move(list));
auto offset = marker
@ -1253,7 +1277,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
ret = STATUS_SUCCESS;
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret);
RAISE_REMOTE_FUSE_SERVER_EVENT(
__FUNCTION__, get_open_file_path(static_cast<native_handle>(handle)),
ret);
return ret;
}
@ -1288,9 +1314,11 @@ auto remote_server::winfsp_set_basic_info(
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type {
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
const auto file_path = get_open_file_path(handle);
const auto file_path =
get_open_file_path(static_cast<native_handle>(handle));
if (attributes == INVALID_FILE_ATTRIBUTES) {
attributes = 0;
} else if (attributes == 0) {
@ -1337,7 +1365,9 @@ auto remote_server::winfsp_set_basic_info(
ret = populate_file_info(api_path, *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<native_handle>(handle)),
ret);
return ret;
}
@ -1346,17 +1376,24 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
remote::file_info *file_info)
-> packet::error_type {
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
const auto res = set_allocation_size ? 0 : ftruncate(handle, new_size);
const auto res =
set_allocation_size
? 0
: ftruncate(static_cast<native_handle>(handle), new_size);
ret = ((res < 0) ? utils::unix_error_to_windows(errno) : 0);
if (ret == 0) {
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<native_handle>(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<native_handle>(handle)),
ret);
return ret;
}
@ -1375,9 +1412,11 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
-> packet::error_type {
*bytes_transferred = 0;
const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
auto ret =
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
const auto api_path = construct_api_path(get_open_file_path(handle));
const auto api_path = construct_api_path(
get_open_file_path(static_cast<native_handle>(handle)));
const auto file_size = drive_.get_file_size(api_path);
if (write_to_end) {
offset = file_size;
@ -1389,7 +1428,7 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
ret = STATUS_SUCCESS;
should_write = false;
} else if ((offset + length) > file_size) {
length = static_cast<UINT64>(file_size - offset);
length = static_cast<UINT32>(file_size - offset);
}
}
@ -1397,9 +1436,10 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
if (length > 0) {
const auto res = pwrite64(handle, buffer, length, offset);
if (res >= 0) {
*bytes_transferred = res;
ret = populate_file_info(
construct_api_path(get_open_file_path(handle)), *file_info);
*bytes_transferred = static_cast<UINT32>(res);
ret = populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))),
*file_info);
} else {
ret = utils::unix_error_to_windows(errno);
}
@ -1407,7 +1447,9 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
}
}
RAISE_REMOTE_FUSE_SERVER_EVENT(__FUNCTION__, get_open_file_path(handle), ret);
RAISE_REMOTE_FUSE_SERVER_EVENT(
__FUNCTION__, get_open_file_path(static_cast<native_handle>(handle)),
ret);
return ret;
}