From dc85194fac9f0527a15cf147fe75a15a7e573a1e Mon Sep 17 00:00:00 2001 From: Lioncache Date: Mon, 18 Dec 2023 10:48:42 -0500 Subject: Common/TraversalServer: Make use of fmt over sprintf where applicable Resolves some deprecation warnings on macOS. This is better anyway, given fmt has generic type formatting. --- Source/Core/Common/TraversalServer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common/TraversalServer.cpp') diff --git a/Source/Core/Common/TraversalServer.cpp b/Source/Core/Common/TraversalServer.cpp index 5991de9e99..784ef9d743 100644 --- a/Source/Core/Common/TraversalServer.cpp +++ b/Source/Core/Common/TraversalServer.cpp @@ -18,6 +18,8 @@ #include #include +#include + #ifdef HAVE_LIBSYSTEMD #include #endif @@ -177,17 +179,17 @@ static sockaddr_in6 MakeSinAddr(const Common::TraversalInetAddress& addr) static void GetRandomHostId(Common::TraversalHostId* hostId) { - char buf[9]; + char buf[9]{}; const u32 num = Common::Random::GenerateValue(); - sprintf(buf, "%08x", num); + fmt::format_to_n(buf, sizeof(buf) - 1, "{:08x}", num); memcpy(hostId->data(), buf, 8); } static const char* SenderName(sockaddr_in6* addr) { - static char buf[INET6_ADDRSTRLEN + 10]; + static char buf[INET6_ADDRSTRLEN + 10]{}; inet_ntop(PF_INET6, &addr->sin6_addr, buf, sizeof(buf)); - sprintf(buf + strlen(buf), ":%d", ntohs(addr->sin6_port)); + fmt::format_to(buf + strlen(buf), ":{}", ntohs(addr->sin6_port)); return buf; } -- cgit v1.2.3