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`
This commit is contained in:
Weiyi Wang 2018-09-06 16:03:28 -04:00
parent eca98eeb3e
commit 7d8f115185
158 changed files with 669 additions and 634 deletions

View file

@ -100,7 +100,7 @@ static std::mutex beacon_mutex;
// Number of beacons to store before we start dropping the old ones.
// TODO(Subv): Find a more accurate value for this limit.
constexpr size_t MaxBeaconFrames = 15;
constexpr std::size_t MaxBeaconFrames = 15;
// List of the last <MaxBeaconFrames> beacons received from the network.
static std::list<Network::WifiPacket> received_beacons;
@ -160,11 +160,11 @@ static void BroadcastNodeMap() {
packet.channel = network_channel;
packet.type = Network::WifiPacket::PacketType::NodeMap;
packet.destination_address = Network::BroadcastMac;
size_t size = node_map.size();
std::size_t size = node_map.size();
using node_t = decltype(node_map)::value_type;
packet.data.resize(sizeof(size) + (sizeof(node_t::first) + sizeof(node_t::second)) * size);
std::memcpy(packet.data.data(), &size, sizeof(size));
size_t offset = sizeof(size);
std::size_t offset = sizeof(size);
for (const auto& node : node_map) {
std::memcpy(packet.data.data() + offset, node.first.data(), sizeof(node.first));
std::memcpy(packet.data.data() + offset + sizeof(node.first), &node.second,
@ -178,12 +178,12 @@ static void BroadcastNodeMap() {
static void HandleNodeMapPacket(const Network::WifiPacket& packet) {
std::lock_guard<std::mutex> lock(connection_status_mutex);
node_map.clear();
size_t num_entries;
std::size_t num_entries;
Network::MacAddress address;
u16 id;
std::memcpy(&num_entries, packet.data.data(), sizeof(num_entries));
size_t offset = sizeof(num_entries);
for (size_t i = 0; i < num_entries; ++i) {
std::size_t offset = sizeof(num_entries);
for (std::size_t i = 0; i < num_entries; ++i) {
std::memcpy(&address, packet.data.data() + offset, sizeof(address));
std::memcpy(&id, packet.data.data() + offset + sizeof(address), sizeof(id));
node_map[address] = id;
@ -306,7 +306,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) {
node_info.clear();
node_info.reserve(network_info.max_nodes);
for (size_t index = 0; index < logoff.connected_nodes; ++index) {
for (std::size_t index = 0; index < logoff.connected_nodes; ++index) {
connection_status.node_bitmask |= 1 << index;
connection_status.changed_nodes |= 1 << index;
connection_status.nodes[index] = logoff.nodes[index].network_node_id;
@ -332,7 +332,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) {
node_info.clear();
node_info.reserve(network_info.max_nodes);
for (size_t index = 0; index < logoff.connected_nodes; ++index) {
for (std::size_t index = 0; index < logoff.connected_nodes; ++index) {
if ((connection_status.node_bitmask & (1 << index)) == 0) {
connection_status.changed_nodes |= 1 << index;
}
@ -584,7 +584,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
Kernel::MappedBuffer out_buffer = rp.PopMappedBuffer();
ASSERT(out_buffer.GetSize() == out_buffer_size);
size_t cur_buffer_size = sizeof(BeaconDataReplyHeader);
std::size_t cur_buffer_size = sizeof(BeaconDataReplyHeader);
// Retrieve all beacon frames that were received from the desired mac address.
auto beacons = GetReceivedBeacons(mac_address);
@ -736,7 +736,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
return;
}
constexpr size_t MaxBindNodes = 16;
constexpr std::size_t MaxBindNodes = 16;
if (channel_data.size() >= MaxBindNodes) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS,
@ -1027,7 +1027,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
dest_address = network_info.host_mac_address;
}
constexpr size_t MaxSize = 0x5C6;
constexpr std::size_t MaxSize = 0x5C6;
if (data_size > MaxSize) {
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));

View file

@ -16,7 +16,7 @@
namespace Service {
namespace NWM {
const size_t ApplicationDataSize = 0xC8;
const std::size_t ApplicationDataSize = 0xC8;
const u8 DefaultNetworkChannel = 11;
// Number of milliseconds in a TU.

View file

@ -241,8 +241,8 @@ void DecryptBeacon(const NetworkInfo& network_info, std::vector<u8>& buffer) {
*/
std::vector<u8> GenerateNintendoFirstEncryptedDataTag(const NetworkInfo& network_info,
const NodeList& nodes) {
const size_t payload_size =
std::min<size_t>(EncryptedDataSizeCutoff, nodes.size() * sizeof(NodeInfo));
const std::size_t payload_size =
std::min<std::size_t>(EncryptedDataSizeCutoff, nodes.size() * sizeof(NodeInfo));
EncryptedDataTag tag{};
tag.header.tag_id = static_cast<u8>(TagId::VendorSpecific);
@ -273,9 +273,9 @@ std::vector<u8> GenerateNintendoSecondEncryptedDataTag(const NetworkInfo& networ
if (nodes.size() * sizeof(NodeInfo) <= EncryptedDataSizeCutoff)
return {};
const size_t payload_size = nodes.size() * sizeof(NodeInfo) - EncryptedDataSizeCutoff;
const std::size_t payload_size = nodes.size() * sizeof(NodeInfo) - EncryptedDataSizeCutoff;
const size_t tag_length = sizeof(EncryptedDataTag) - sizeof(TagHeader) + payload_size;
const std::size_t tag_length = sizeof(EncryptedDataTag) - sizeof(TagHeader) + payload_size;
// TODO(Subv): What does the 3DS do when a game has too much data to fit into the tag?
ASSERT_MSG(tag_length <= 255, "Data is too big.");

View file

@ -203,7 +203,7 @@ static std::vector<u8> DecryptDataFrame(const std::vector<u8>& encrypted_payload
df.ChannelMessageEnd(CryptoPP::DEFAULT_CHANNEL);
df.SetRetrievalChannel(CryptoPP::DEFAULT_CHANNEL);
size_t size = df.MaxRetrievable();
std::size_t size = df.MaxRetrievable();
std::vector<u8> pdata(size);
df.Get(pdata.data(), size);
@ -257,7 +257,7 @@ static std::vector<u8> EncryptDataFrame(const std::vector<u8>& payload,
df.SetRetrievalChannel(CryptoPP::DEFAULT_CHANNEL);
size_t size = df.MaxRetrievable();
std::size_t size = df.MaxRetrievable();
std::vector<u8> cipher(size);
df.Get(cipher.data(), size);
@ -357,7 +357,7 @@ std::vector<u8> GenerateEAPoLLogoffFrame(const MacAddress& mac_address, u16 netw
eapol_logoff.connected_nodes = total_nodes;
eapol_logoff.max_nodes = max_nodes;
for (size_t index = 0; index < total_nodes; ++index) {
for (std::size_t index = 0; index < total_nodes; ++index) {
const auto& node_info = nodes[index];
auto& node = eapol_logoff.nodes[index];