diff --git a/include/fast_io_driver/mfc_impl/mfc_file.h b/include/fast_io_driver/mfc_impl/mfc_file.h index 8f259a1f3..0c6675064 100644 --- a/include/fast_io_driver/mfc_impl/mfc_file.h +++ b/include/fast_io_driver/mfc_impl/mfc_file.h @@ -99,7 +99,7 @@ inline void mfc_scatter_write_impl(CFile *cfp, io_scatter_t const *scats, ::std: auto e{scats + n}; for (; i != e; ++i) { - mfc_write_n_impl(cfp, reinterpret_cast<::std::byte const *>(scats->base), scats->len); + mfc_write_n_impl(cfp, reinterpret_cast<::std::byte const *>(i->base), i->len); } } diff --git a/include/fast_io_hosted/platforms/posix.h b/include/fast_io_hosted/platforms/posix.h index 2c877e53c..0b4c8b984 100644 --- a/include/fast_io_hosted/platforms/posix.h +++ b/include/fast_io_hosted/platforms/posix.h @@ -1273,7 +1273,14 @@ class basic_posix_family_file : public basic_posix_family_io_observerfd = ::fast_io::details::sys_dup2(dp.fd, this->fd); + if (this->fd == -1) [[unlikely]] + { + this->fd = ::fast_io::details::sys_dup(dp.fd); + } + else + { + this->fd = ::fast_io::details::sys_dup2(dp.fd, this->fd); + } return *this; } inline constexpr basic_posix_family_file(basic_posix_family_file &&__restrict b) noexcept diff --git a/include/fast_io_hosted/platforms/posix_file_lock.h b/include/fast_io_hosted/platforms/posix_file_lock.h index 7ec855cbf..9812aaadc 100644 --- a/include/fast_io_hosted/platforms/posix_file_lock.h +++ b/include/fast_io_hosted/platforms/posix_file_lock.h @@ -6,7 +6,7 @@ namespace details { inline int fcntl_file_lock(int fd, int cmd, struct flock const *lockp) { - return ::fcntl(fd, cmd, __builtin_addressof(lockp)); + return ::fcntl(fd, cmd, lockp); } inline void posix_file_lock_lock_common_impl(int fd, struct flock const &lockp)