From 64aa7f3b8f263a9162c4e081c5b6433300fe1325 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 13 Mar 2017 13:59:43 -0400 Subject: [PATCH] SI_DeviceGBA: Use std::array class members instead of C arrays --- Source/Core/Core/HW/SI/SI_DeviceGBA.cpp | 17 +++++++++-------- Source/Core/Core/HW/SI/SI_DeviceGBA.h | 7 ++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp index 1df88990b2..ae3c385ca5 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp @@ -4,6 +4,7 @@ #include "Core/HW/SI/SI_DeviceGBA.h" +#include #include #include #include @@ -237,7 +238,7 @@ void GBASockServer::Send(const u8* si_buffer) if (!GetAvailableSock(client)) return; - for (int i = 0; i < 5; i++) + for (size_t i = 0; i < send_data.size(); i++) send_data[i] = si_buffer[i ^ 3]; cmd = (u8)send_data[0]; @@ -250,9 +251,9 @@ void GBASockServer::Send(const u8* si_buffer) client->setBlocking(false); sf::Socket::Status status; if (cmd == CMD_WRITE) - status = client->send(send_data, sizeof(send_data)); + status = client->send(send_data.data(), send_data.size()); else - status = client->send(send_data, 1); + status = client->send(send_data.data(), 1); if (cmd != CMD_STATUS) booted = true; @@ -282,7 +283,7 @@ int GBASockServer::Receive(u8* si_buffer) Selector.wait(sf::milliseconds(1000)); } - sf::Socket::Status recv_stat = client->receive(recv_data, sizeof(recv_data), num_received); + sf::Socket::Status recv_stat = client->receive(recv_data.data(), recv_data.size(), num_received); if (recv_stat == sf::Socket::Disconnected) { Disconnect(); @@ -292,8 +293,8 @@ int GBASockServer::Receive(u8* si_buffer) if (recv_stat == sf::Socket::NotReady) num_received = 0; - if (num_received > sizeof(recv_data)) - num_received = sizeof(recv_data); + if (num_received > recv_data.size()) + num_received = recv_data.size(); if (num_received > 0) { @@ -312,7 +313,7 @@ int GBASockServer::Receive(u8* si_buffer) } #endif - for (int i = 0; i < 5; i++) + for (size_t i = 0; i < recv_data.size(); i++) si_buffer[i ^ 3] = recv_data[i]; } @@ -333,7 +334,7 @@ int CSIDevice_GBA::RunBuffer(u8* _pBuffer, int _iLength) { if (!waiting_for_response) { - for (int i = 0; i < 5; i++) + for (size_t i = 0; i < send_data.size(); i++) send_data[i] = _pBuffer[i ^ 3]; num_data_received = 0; diff --git a/Source/Core/Core/HW/SI/SI_DeviceGBA.h b/Source/Core/Core/HW/SI/SI_DeviceGBA.h index 09c6041bad..c96193d98e 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGBA.h +++ b/Source/Core/Core/HW/SI/SI_DeviceGBA.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include @@ -33,8 +34,8 @@ public: private: std::unique_ptr client; std::unique_ptr clock_sync; - char send_data[5] = {}; - char recv_data[5] = {}; + std::array send_data{}; + std::array recv_data{}; u64 time_cmd_sent = 0; u64 last_time_slice = 0; @@ -55,7 +56,7 @@ public: bool GetData(u32& _Hi, u32& _Low) override { return false; } void SendCommand(u32 _Cmd, u8 _Poll) override {} private: - u8 send_data[5] = {}; + std::array send_data{}; int num_data_received = 0; u64 timestamp_sent = 0; bool waiting_for_response = false;