util: avoid C-style arrays

This commit is contained in:
Michele Caini 2024-10-23 10:38:32 +02:00
parent 998a86975b
commit 58b8b3d610
2 changed files with 6 additions and 6 deletions

View File

@ -238,11 +238,11 @@ struct cpu_info {
* \brief Interface address. * \brief Interface address.
*/ */
struct interface_address { struct interface_address {
std::string name; /*!< The name of the interface (as an example _eth0_). */ std::string name; /*!< The name of the interface (as an example _eth0_). */
char physical[6]; /*!< The physical address. */ std::array<char, 6u> physical; /*!< The physical address. */
bool internal; /*!< True if it is an internal interface (as an example _loopback_), false otherwise. */ bool internal; /*!< True if it is an internal interface (as an example _loopback_), false otherwise. */
socket_address address; /*!< The address of the given interface. */ socket_address address; /*!< The address of the given interface. */
socket_address netmask; /*!< The netmask of the given interface. */ socket_address netmask; /*!< The netmask of the given interface. */
}; };
namespace details { namespace details {

View File

@ -239,7 +239,7 @@ UVW_INLINE std::vector<interface_address> utilities::interface_addresses() noexc
interface_address iface_addr; interface_address iface_addr;
iface_addr.name = ifaces[next].name; iface_addr.name = ifaces[next].name;
std::copy(ifaces[next].phys_addr, (ifaces[next].phys_addr + 6), iface_addr.physical); std::copy(ifaces[next].phys_addr, (ifaces[next].phys_addr + 6), iface_addr.physical.data());
iface_addr.internal = ifaces[next].is_internal == 0 ? false : true; iface_addr.internal = ifaces[next].is_internal == 0 ? false : true;
if(ifaces[next].address.address4.sin_family == AF_INET) { if(ifaces[next].address.address4.sin_family == AF_INET) {