From affe92898725d20ad0bac7e090063dad2f2cecf9 Mon Sep 17 00:00:00 2001 From: Lioncache Date: Mon, 18 Dec 2023 10:55:31 -0500 Subject: [PATCH] Common/TraversalServer: Make use of fmt more We can convert printf and fprintf over to the use of fmt as well, given that we've converted the sprintf calls over. --- Source/Core/Common/TraversalServer.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/Core/Common/TraversalServer.cpp b/Source/Core/Common/TraversalServer.cpp index 784ef9d743..3d449256d1 100644 --- a/Source/Core/Common/TraversalServer.cpp +++ b/Source/Core/Common/TraversalServer.cpp @@ -87,12 +87,12 @@ retry: } } #if DEBUG - printf("failed to find key '"); + fmt::print("failed to find key '"); for (size_t i = 0; i < sizeof(key); i++) { - printf("%02x", ((u8*)&key)[i]); + fmt::print("{:02x}", ((u8*)&key)[i]); } - printf("'\n"); + fmt::print("'\n"); #endif result.found = false; return result; @@ -133,7 +133,7 @@ static Common::TraversalInetAddress MakeInetAddress(const sockaddr_in6& addr) { if (addr.sin6_family != AF_INET6) { - fprintf(stderr, "bad sockaddr_in6\n"); + fmt::print(stderr, "bad sockaddr_in6\n"); exit(1); } u32* words = (u32*)addr.sin6_addr.s6_addr; @@ -197,8 +197,8 @@ static void TrySend(const void* buffer, size_t size, sockaddr_in6* addr, bool fr { #if DEBUG const auto* packet = static_cast(buffer); - printf("%s-> %d %llu %s\n", fromAlt ? "alt " : "", static_cast(packet->type), - static_cast(packet->requestId), SenderName(addr)); + fmt::print("{}-> {} {} {}\n", fromAlt ? "alt " : "", static_cast(packet->type), + static_cast(packet->requestId), SenderName(addr)); #endif if ((size_t)sendto(fromAlt ? sockAlt : sock, buffer, size, 0, (sockaddr*)addr, sizeof(*addr)) != size) @@ -271,8 +271,8 @@ static void ResendPackets() static void HandlePacket(Common::TraversalPacket* packet, sockaddr_in6* addr, bool toAlt) { #if DEBUG - printf("<- %d %llu %s\n", static_cast(packet->type), - static_cast(packet->requestId), SenderName(addr)); + fmt::print("<- {} {} {}\n", static_cast(packet->type), + static_cast(packet->requestId), SenderName(addr)); #endif bool packetOk = true; switch (packet->type) @@ -377,8 +377,8 @@ static void HandlePacket(Common::TraversalPacket* packet, sockaddr_in6* addr, bo break; } default: - fprintf(stderr, "received unknown packet type %d from %s\n", static_cast(packet->type), - SenderName(addr)); + fmt::print(stderr, "received unknown packet type {} from {}\n", static_cast(packet->type), + SenderName(addr)); break; } if (packet->type != Common::TraversalPacketType::Ack) @@ -516,7 +516,7 @@ int main() } else if ((size_t)rv < sizeof(packet)) { - fprintf(stderr, "received short packet from %s\n", SenderName(&raddr)); + fmt::print(stderr, "received short packet from {}\n", SenderName(&raddr)); } else {