From 6a95e0877b3d67eeb7fdd31df4800cfa1fb370dc Mon Sep 17 00:00:00 2001 From: brian218 Date: Mon, 6 Mar 2023 23:55:28 +0800 Subject: [PATCH] sys_fs: Fix warning C6262 --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 8a558d2b6e..7a7b59c220 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -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 buf, u64 size) { // Copy data from intermediate buffer (avoid passing vm pointer to a native API) - uchar local_buf[65536]; + std::vector local_buf(std::min(size, 65536)); u64 result = 0; while (result < size) { - const u64 block = std::min(size - result, sizeof(local_buf)); - const u64 nread = file.read(+local_buf, block); + const u64 block = std::min(size - result, local_buf.size()); + const u64 nread = file.read(+local_buf.data(), block); - std::memcpy(static_cast(buf.get_ptr()) + result, local_buf, nread); + std::memcpy(static_cast(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 buf, u64 size) u64 lv2_file::op_write(const fs::file& file, vm::cptr buf, u64 size) { // Copy data to intermediate buffer (avoid passing vm pointer to a native API) - uchar local_buf[65536]; + std::vector local_buf(std::min(size, 65536)); u64 result = 0; while (result < size) { - const u64 block = std::min(size - result, sizeof(local_buf)); - std::memcpy(local_buf, static_cast(buf.get_ptr()) + result, block); - const u64 nwrite = file.write(+local_buf, block); + const u64 block = std::min(size - result, local_buf.size()); + std::memcpy(local_buf.data(), static_cast(buf.get_ptr()) + result, block); + const u64 nwrite = file.write(+local_buf.data(), block); result += nwrite; if (nwrite < block)