mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-03 16:16:05 +00:00
Common/Network: Get rid of out parameters for MAC address utilities
Given we have std::array and std::optional, we can use these in conjunction with one another to avoid the need for out parameters.
This commit is contained in:
parent
70417c8d16
commit
ce69201f33
9 changed files with 77 additions and 58 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "Core/HW/EXI/EXI_DeviceEthernet.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
|
@ -33,16 +34,17 @@ CEXIETHERNET::CEXIETHERNET()
|
|||
// Parse MAC address from config, and generate a new one if it doesn't
|
||||
// exist or can't be parsed.
|
||||
std::string& mac_addr_setting = SConfig::GetInstance().m_bba_mac;
|
||||
u8 mac_addr[Common::MAC_ADDRESS_SIZE] = {0};
|
||||
std::optional<Common::MACAddress> mac_addr = Common::StringToMacAddress(mac_addr_setting);
|
||||
|
||||
if (!Common::StringToMacAddress(mac_addr_setting, mac_addr))
|
||||
if (!mac_addr)
|
||||
{
|
||||
Common::GenerateMacAddress(Common::MACConsumer::BBA, mac_addr);
|
||||
mac_addr_setting = Common::MacAddressToString(mac_addr);
|
||||
mac_addr = Common::GenerateMacAddress(Common::MACConsumer::BBA);
|
||||
mac_addr_setting = Common::MacAddressToString(mac_addr.value());
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
memcpy(&mBbaMem[BBA_NAFR_PAR0], mac_addr, Common::MAC_ADDRESS_SIZE);
|
||||
const auto& mac = mac_addr.value();
|
||||
memcpy(&mBbaMem[BBA_NAFR_PAR0], mac.data(), mac.size());
|
||||
|
||||
// HACK: .. fully established 100BASE-T link
|
||||
mBbaMem[BBA_NWAYS] = NWAYS_LS100 | NWAYS_LPNWAY | NWAYS_100TXF | NWAYS_ANCLPT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue