From 8790f2469c6f23aeb1fb3fa5a6658b856a6f70f8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 5 Jul 2024 18:38:52 +0200 Subject: [PATCH] lib/fmt/SocketAddressFormatter: switch to the new net/FormatAddress library --- src/lib/fmt/SocketAddressFormatter.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/fmt/SocketAddressFormatter.cxx b/src/lib/fmt/SocketAddressFormatter.cxx index 048ea981f..43798c8cb 100644 --- a/src/lib/fmt/SocketAddressFormatter.cxx +++ b/src/lib/fmt/SocketAddressFormatter.cxx @@ -2,11 +2,19 @@ // author: Max Kellermann #include "SocketAddressFormatter.hxx" -#include "net/ToString.hxx" +#include "net/FormatAddress.hxx" auto fmt::formatter::format(SocketAddress address, format_context &ctx) const -> format_context::iterator { - return formatter::format(ToString(address), ctx); + char buffer[256]; + std::string_view s; + + if (ToString(std::span{buffer}, address)) + s = buffer; + else + s = "?"; + + return formatter::format(s, ctx); }