lib/avahi/Publisher: use libfmt

This commit is contained in:
Max Kellermann 2023-03-06 19:57:53 +01:00
parent 1132a1c9a7
commit 00d5e6e9c7

View File

@ -13,9 +13,10 @@
#include <avahi-common/malloc.h> #include <avahi-common/malloc.h>
#include <avahi-common/alternative.h> #include <avahi-common/alternative.h>
#include <fmt/core.h>
#include <cassert> #include <cassert>
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
namespace Avahi { namespace Avahi {
@ -31,11 +32,9 @@ namespace Avahi {
* AVAHI_BROWSER_NEW. * AVAHI_BROWSER_NEW.
*/ */
static std::string static std::string
MakePidName(const char *prefix) MakePidName(const char *prefix) noexcept
{ {
char buffer[256]; return fmt::format("{}[{}]", prefix, getpid());
snprintf(buffer, sizeof(buffer), "%s[%u]", prefix, (unsigned)getpid());
return buffer;
} }
Publisher::Publisher(Client &_client, const char *_name, Publisher::Publisher(Client &_client, const char *_name,