Repository: xbmc/xbmc
File: xbmc/platform/win32/network/NetworkWin32.cpp (C++)

Code before:
      break;
    }

    default:
      return false;
  }

  DWORD lastErr = GetLastError();
  if (lastErr != ERROR_SUCCESS && lastErr != IP_REQ_TIMED_OUT)
    CLog::Log(LOGERROR, "{} - {} failed - {}", __FUNCTION__,
              host.sa_family == AF_INET ? "IcmpSendEcho2" : "Icmp6SendEcho2",
              CWIN32Util::WUSysMsg(lastErr));

  IcmpCloseHandle (hIcmpFile);

  if (dwRetVal > 0U)
  {
    PICMP_ECHO_REPLY pEchoReply = reinterpret_cast<PICMP_ECHO_REPLY>(ReplyBuffer);
    return pEchoReply->Status == IP_SUCCESS;
  }
  return false;
}

bool CNetworkInterfaceWin32::GetHostMacAddress(unsigned long host, std::string& mac) const
{
  struct sockaddr sockHost = {};
  sockHost.sa_family = AF_INET;
  reinterpret_cast<struct sockaddr_in&>(sockHost).sin_addr.S_un.S_addr = host;
  return GetHostMacAddress(&sockHost, mac);
}

bool CNetworkInterfaceWin32::GetHostMacAddress(struct sockaddr* host, std::string& mac) const
{
  DWORD InterfaceIndex;
  if (GetBestInterfaceEx(host, &InterfaceIndex) != NO_ERROR)
    return false;

  NET_LUID luid = {};
  if (ConvertInterfaceIndexToLuid(InterfaceIndex, &luid) != NO_ERROR)
    return false;

  MIB_IPNET_ROW2 neighborIp = {};
  neighborIp.InterfaceLuid = luid;
  switch (host->sa_family)
  {
    case AF_INET:
      memcpy(&neighborIp.Address.Ipv4, host, sizeof(sockaddr_in));
      break;
    case AF_INET6:
      memcpy(&neighborIp.Address.Ipv6, host, sizeof(sockaddr_in6));
      break;

Review comment (suggestion):
```suggestion
  sockaddr sockHost = {};
```
Seems rare the use of "struct" word here. I mean struct is for define a struct but here is declare a struct already defined in Windows headers.

Same thing in `CNetworkWin32::PingHost` and `CNetworkInterfaceWin32::GetHostMacAddress`

Code after:
      break;
    }

    default:
      return false;
  }

  DWORD lastErr = GetLastError();
  if (lastErr != ERROR_SUCCESS && lastErr != IP_REQ_TIMED_OUT)
    CLog::Log(LOGERROR, "{} - {} failed - {}", __FUNCTION__,
              host.sa_family == AF_INET ? "IcmpSendEcho2" : "Icmp6SendEcho2",
              CWIN32Util::WUSysMsg(lastErr));

  IcmpCloseHandle (hIcmpFile);

  if (dwRetVal > 0U)
  {
    PICMP_ECHO_REPLY pEchoReply = reinterpret_cast<PICMP_ECHO_REPLY>(ReplyBuffer);
    return pEchoReply->Status == IP_SUCCESS;
  }
  return false;
}

bool CNetworkInterfaceWin32::GetHostMacAddress(unsigned long host, std::string& mac) const
{
  sockaddr sockHost{};
  sockHost.sa_family = AF_INET;
  reinterpret_cast<struct sockaddr_in&>(sockHost).sin_addr.S_un.S_addr = host;
  return GetHostMacAddress(&sockHost, mac);
}

bool CNetworkInterfaceWin32::GetHostMacAddress(struct sockaddr* host, std::string& mac) const
{
  DWORD InterfaceIndex;
  if (GetBestInterfaceEx(host, &InterfaceIndex) != NO_ERROR)
    return false;

  NET_LUID luid{};
  if (ConvertInterfaceIndexToLuid(InterfaceIndex, &luid) != NO_ERROR)
    return false;

  MIB_IPNET_ROW2 neighborIp{};
  neighborIp.InterfaceLuid = luid;
  switch (host->sa_family)
  {
    case AF_INET:
      memcpy(&neighborIp.Address.Ipv4, host, sizeof(sockaddr_in));
      break;
    case AF_INET6:
      memcpy(&neighborIp.Address.Ipv6, host, sizeof(sockaddr_in6));
      break;