yuzu-emu
/
yuzu
Archived
1
0
Fork 0

network: correct formatting in network.cpp and network_interface.cpp

This commit is contained in:
Sönke Holz 2021-08-12 22:15:48 +02:00
parent 1e98e73828
commit 21743daf38
2 changed files with 6 additions and 8 deletions

View File

@ -13,13 +13,13 @@
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#elif YUZU_UNIX #elif YUZU_UNIX
#include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <poll.h> #include <poll.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h> #include <unistd.h>
#else #else
#error "Unimplemented platform" #error "Unimplemented platform"
@ -363,8 +363,8 @@ NetworkInstance::~NetworkInstance() {
std::optional<IPv4Address> GetHostIPv4Address() { std::optional<IPv4Address> GetHostIPv4Address() {
const std::string& selected_network_interface = Settings::values.network_interface.GetValue(); const std::string& selected_network_interface = Settings::values.network_interface.GetValue();
const auto network_interfaces = Network::GetAvailableNetworkInterfaces(); const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
ASSERT_MSG(network_interfaces.size() > 0, "GetAvailableNetworkInterfaces returned no interfaces"); ASSERT_MSG(network_interfaces.size() > 0,
"GetAvailableNetworkInterfaces returned no interfaces");
const auto res = std::ranges::find_if(network_interfaces, const auto res = std::ranges::find_if(network_interfaces,
[&selected_network_interface](const auto& interface) { [&selected_network_interface](const auto& interface) {

View File

@ -12,9 +12,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include <iphlpapi.h> #include <iphlpapi.h>
#else #else
#include <cerrno>
#include <ifaddrs.h> #include <ifaddrs.h>
#include <net/if.h> #include <net/if.h>
#include <cerrno>
#endif #endif
namespace Network { namespace Network {
@ -61,8 +61,7 @@ std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
result.push_back(NetworkInterface{ result.push_back(NetworkInterface{
.name{Common::UTF16ToUTF8(std::wstring{current_address->FriendlyName})}, .name{Common::UTF16ToUTF8(std::wstring{current_address->FriendlyName})},
.ip_address{ip_addr} .ip_address{ip_addr}});
});
} }
} else { } else {
LOG_ERROR(Network, "Failed to get network interfaces with GetAdaptersAddresses"); LOG_ERROR(Network, "Failed to get network interfaces with GetAdaptersAddresses");
@ -99,8 +98,7 @@ std::vector<NetworkInterface> GetAvailableNetworkInterfaces() {
result.push_back(NetworkInterface{ result.push_back(NetworkInterface{
.name{ifa->ifa_name}, .name{ifa->ifa_name},
.ip_address{std::bit_cast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr} .ip_address{std::bit_cast<struct sockaddr_in>(*ifa->ifa_addr).sin_addr}});
});
} }
freeifaddrs(ifaddr); freeifaddrs(ifaddr);