From 25165c1deaaa69ba10a8231200739b9d932f78a7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 12 Jun 2023 16:45:25 +0200 Subject: [PATCH] resolved: add DNS_RESOURCE_KEY_TO_STRING() macro helper This does the usual compound init trick to get formatted strings of stuff. We should probably port various pieces of code over to using this. --- src/resolve/resolved-dns-rr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h index a3fa24eaf9b..fd15cc343d8 100644 --- a/src/resolve/resolved-dns-rr.h +++ b/src/resolve/resolved-dns-rr.h @@ -317,6 +317,9 @@ int dns_resource_key_match_soa(const DnsResourceKey *key, const DnsResourceKey * char* dns_resource_key_to_string(const DnsResourceKey *key, char *buf, size_t buf_size); ssize_t dns_resource_record_payload(DnsResourceRecord *rr, void **out); +#define DNS_RESOURCE_KEY_TO_STRING(key) \ + dns_resource_key_to_string(key, (char[DNS_RESOURCE_KEY_STRING_MAX]) {}, DNS_RESOURCE_KEY_STRING_MAX) + DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref); static inline bool dns_key_is_shared(const DnsResourceKey *key) { -- 2.47.3