From f8ab6e9247780b4601f5fe61136c8016581aa0bf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 5 Jun 2020 20:52:25 -0400 Subject: [PATCH] nwm: Eliminate signed conversion warnings While we're at it, we can also improve some of the allocations and copying that would be going on in one case by preallocating and then emplacing before modifying. --- src/core/hle/service/nwm/nwm_uds.cpp | 12 ++++++------ src/core/hle/service/nwm/uds_beacon.cpp | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 831f6c87e..6454a2bdd 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1314,23 +1314,23 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx, u16 command_id) // TODO(Subv): Verify the MD5 hash of the data and return 0xE1211005 if invalid. - u8 num_nodes = net_info.max_nodes; + const std::size_t num_nodes = net_info.max_nodes; std::vector nodes; + nodes.reserve(num_nodes); - for (int i = 0; i < num_nodes; ++i) { + for (std::size_t i = 0; i < num_nodes; ++i) { BeaconNodeInfo info; std::memcpy(&info, beacon_data.data() + sizeof(beacon_header) + i * sizeof(info), sizeof(info)); // Deserialize the node information. - NodeInfo node{}; + auto& node = nodes.emplace_back(); node.friend_code_seed = info.friend_code_seed; node.network_node_id = info.network_node_id; - for (int i = 0; i < info.username.size(); ++i) + for (std::size_t i = 0; i < info.username.size(); ++i) { node.username[i] = info.username[i]; - - nodes.push_back(node); + } } IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); diff --git a/src/core/hle/service/nwm/uds_beacon.cpp b/src/core/hle/service/nwm/uds_beacon.cpp index 293506a0a..e12895ccf 100644 --- a/src/core/hle/service/nwm/uds_beacon.cpp +++ b/src/core/hle/service/nwm/uds_beacon.cpp @@ -197,8 +197,9 @@ std::vector GeneratedEncryptedData(const NetworkInfo& network_info, const No BeaconNodeInfo info{}; info.friend_code_seed = node.friend_code_seed; info.network_node_id = node.network_node_id; - for (int i = 0; i < info.username.size(); ++i) + for (std::size_t i = 0; i < info.username.size(); ++i) { info.username[i] = node.username[i]; + } buffer.insert(buffer.end(), reinterpret_cast(&info), reinterpret_cast(&info) + sizeof(info));