misc: fix issues pointed out by msvc (#7316)

* do not move constant variables

* applet_manager: avoid possible use after move

* use constant references where pointed out by msvc

* extra_hid: initialize response

* ValidateSaveState: passing slot separately is not necessary

* common: mark HashCombine as nodiscard

* cityhash: remove use of using namespace std

* Prefix all size_t with std::

done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
based on 7d8f115

* shared_memory.cpp: fix log error format

* fix compiling with pch off
This commit is contained in:
Vitor K 2024-01-07 17:37:42 -03:00 committed by GitHub
parent 6069fac76d
commit c8c2beaeff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 181 additions and 167 deletions

View file

@ -713,6 +713,7 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id,
.signal = SignalType::DspSleep,
.object = std::move(object),
});
return ResultSuccess;
}
auto sys_lib_slot = GetAppletSlotFromPos(AppletPos::SysLibrary);
@ -728,6 +729,7 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id,
.signal = SignalType::DspSleep,
.object = std::move(object),
});
return ResultSuccess;
}
return ResultSuccess;

View file

@ -399,8 +399,8 @@ Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHead
}
}
ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer) {
ResultVal<std::size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset,
const u32 size, Kernel::MappedBuffer& buffer) {
std::optional<NsDataEntry> entry = GetNsDataEntryFromId(ns_data_id);
if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);

View file

@ -36,11 +36,11 @@ constexpr u32 BOSS_EXTDATA_HEADER_LENGTH = 0x18;
constexpr u32 BOSS_S_ENTRY_SIZE = 0xC00;
constexpr u32 BOSS_SAVE_HEADER_SIZE = 4;
constexpr size_t TASK_ID_SIZE = 8;
constexpr size_t URL_SIZE = 0x200;
constexpr size_t HEADERS_SIZE = 0x360;
constexpr size_t CERTIDLIST_SIZE = 3;
constexpr size_t TASKIDLIST_SIZE = 0x400;
constexpr std::size_t TASK_ID_SIZE = 8;
constexpr std::size_t URL_SIZE = 0x200;
constexpr std::size_t HEADERS_SIZE = 0x360;
constexpr std::size_t CERTIDLIST_SIZE = 3;
constexpr std::size_t TASKIDLIST_SIZE = 0x400;
constexpr std::array<u8, 8> boss_system_savedata_id{
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x00,
@ -188,8 +188,8 @@ public:
std::optional<NsDataEntry> GetNsDataEntryFromId(const u32 ns_data_id);
Result GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer);
ResultVal<size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer);
ResultVal<std::size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer);
Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);

View file

@ -649,7 +649,7 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
buffer = {};
}
dest_buffer.Write(buffer.data(), 0,
std::min(static_cast<size_t>(dest_buffer_size), buffer.size()));
std::min(static_cast<std::size_t>(dest_buffer_size), buffer.size()));
rb.Push(ResultSuccess);
rb.PushMappedBuffer(param_buffer);

View file

@ -384,7 +384,7 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
"Config block 0x{:X} with flags {} and size {} was not found, creating "
"from defaults.",
block_id, accesss_flag, size);
auto default_block = GetDefaultConfigBlock(static_cast<ConfigBlockID>(block_id));
const auto& default_block = GetDefaultConfigBlock(static_cast<ConfigBlockID>(block_id));
auto result = CreateConfigBlock(block_id, static_cast<u16>(default_block.data.size()),
default_block.access_flags, default_block.data.data());
if (!result.IsSuccess()) {

View file

@ -107,7 +107,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
Result ret{0};
Kernel::MappedBuffer* buffer;
std::unique_ptr<u8*> data;
size_t read_size;
std::size_t read_size;
};
auto async_data = std::make_shared<AsyncData>();

View file

@ -112,9 +112,9 @@ static URLInfo SplitUrl(const std::string& url) {
};
}
static size_t WriteHeaders(httplib::Stream& stream,
std::span<const Context::RequestHeader> headers) {
size_t write_len = 0;
static std::size_t WriteHeaders(httplib::Stream& stream,
std::span<const Context::RequestHeader> headers) {
std::size_t write_len = 0;
for (const auto& header : headers) {
auto len = stream.write_format("%s: %s\r\n", header.name.c_str(), header.value.c_str());
if (len < 0) {
@ -130,8 +130,8 @@ static size_t WriteHeaders(httplib::Stream& stream,
return write_len;
}
static size_t HandleHeaderWrite(std::vector<Context::RequestHeader>& pending_headers,
httplib::Stream& strm, httplib::Headers& httplib_headers) {
static std::size_t HandleHeaderWrite(std::vector<Context::RequestHeader>& pending_headers,
httplib::Stream& strm, httplib::Headers& httplib_headers) {
std::vector<Context::RequestHeader> final_headers;
std::vector<Context::RequestHeader>::iterator it_pending_headers;
httplib::Headers::iterator it_httplib_headers;
@ -508,7 +508,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
}
Context& http_context = GetContext(async_data->context_handle);
const size_t remaining_data =
const std::size_t remaining_data =
http_context.response.body.size() - http_context.current_copied_data;
if (async_data->buffer_size >= remaining_data) {

View file

@ -217,7 +217,7 @@ public:
std::future<void> request_future;
std::atomic<u64> current_download_size_bytes;
std::atomic<u64> total_download_size_bytes;
size_t current_copied_data;
std::size_t current_copied_data;
bool uses_default_client_cert{};
httplib::Response response;

View file

@ -238,7 +238,7 @@ void ExtraHID::SendHIDStatus() {
float x, y;
std::tie(x, y) = c_stick->GetStatus();
ExtraHIDResponse response;
ExtraHIDResponse response{};
response.c_stick.header.Assign(static_cast<u8>(ResponseID::PollHID));
response.c_stick.c_stick_x.Assign(static_cast<u32>(C_STICK_CENTER + C_STICK_RADIUS * x));
response.c_stick.c_stick_y.Assign(static_cast<u32>(C_STICK_CENTER + C_STICK_RADIUS * y));

View file

@ -1102,7 +1102,7 @@ void SOC_U::SendToOther(Kernel::HLERequestContext& ctx) {
#endif // _WIN32
std::vector<u8> input_buff(len);
input_mapped_buff.Read(input_buff.data(), 0,
std::min(input_mapped_buff.GetSize(), static_cast<size_t>(len)));
std::min(input_mapped_buff.GetSize(), static_cast<std::size_t>(len)));
s32 ret = -1;
if (addr_len > 0) {
@ -1853,7 +1853,7 @@ void SOC_U::GetSockOpt(Kernel::HLERequestContext& ctx) {
if (err == SOCKET_ERROR_VALUE) {
err = TranslateError(GET_ERRNO);
} else {
platform_data.resize(static_cast<size_t>(platform_data_size));
platform_data.resize(static_cast<std::size_t>(platform_data_size));
TranslateSockOptDataFromPlatform(optval, platform_data, level_opt.first,
level_opt.second);
}