From: Lennart Poettering Date: Mon, 12 Jun 2023 14:45:25 +0000 (+0200) Subject: resolved: add DNS_RESOURCE_KEY_TO_STRING() macro helper X-Git-Tag: v254-rc1~212^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=25165c1deaaa69ba10a8231200739b9d932f78a7;p=thirdparty%2Fsystemd.git 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. --- 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) {