sys_fs: Fix warning C6262

This commit is contained in:
brian218 2023-03-06 23:55:28 +08:00 committed by Megamouse
parent 28c37ab465
commit 6a95e0877b

View File

@ -336,16 +336,16 @@ lv2_fs_object::lv2_fs_object(utils::serial& ar, bool)
u64 lv2_file::op_read(const fs::file& file, vm::ptr<void> buf, u64 size)
{
// Copy data from intermediate buffer (avoid passing vm pointer to a native API)
uchar local_buf[65536];
std::vector<uchar> local_buf(std::min<u64>(size, 65536));
u64 result = 0;
while (result < size)
{
const u64 block = std::min<u64>(size - result, sizeof(local_buf));
const u64 nread = file.read(+local_buf, block);
const u64 block = std::min<u64>(size - result, local_buf.size());
const u64 nread = file.read(+local_buf.data(), block);
std::memcpy(static_cast<uchar*>(buf.get_ptr()) + result, local_buf, nread);
std::memcpy(static_cast<uchar*>(buf.get_ptr()) + result, local_buf.data(), nread);
result += nread;
if (nread < block)
@ -360,15 +360,15 @@ u64 lv2_file::op_read(const fs::file& file, vm::ptr<void> buf, u64 size)
u64 lv2_file::op_write(const fs::file& file, vm::cptr<void> buf, u64 size)
{
// Copy data to intermediate buffer (avoid passing vm pointer to a native API)
uchar local_buf[65536];
std::vector<uchar> local_buf(std::min<u64>(size, 65536));
u64 result = 0;
while (result < size)
{
const u64 block = std::min<u64>(size - result, sizeof(local_buf));
std::memcpy(local_buf, static_cast<const uchar*>(buf.get_ptr()) + result, block);
const u64 nwrite = file.write(+local_buf, block);
const u64 block = std::min<u64>(size - result, local_buf.size());
std::memcpy(local_buf.data(), static_cast<const uchar*>(buf.get_ptr()) + result, block);
const u64 nwrite = file.write(+local_buf.data(), block);
result += nwrite;
if (nwrite < block)