diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-09-18 18:03:09 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-09-18 18:34:57 +0200 |
commit | f7923ef318c7a044bce8b19cd14b498ed1013068 (patch) | |
tree | cac11b56523df4396e779e64beff79de3d0284b5 /src/resolve | |
parent | resolvectl: make sd_json_dispatch_field table static (diff) | |
download | systemd-f7923ef318c7a044bce8b19cd14b498ed1013068.tar.xz systemd-f7923ef318c7a044bce8b19cd14b498ed1013068.zip |
resolve: make sd_json_dispatch_field table static
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 6a4bd6aecd..cc7a5b64b6 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -2145,26 +2145,31 @@ int dns_resource_key_to_json(DnsResourceKey *key, sd_json_variant **ret) { } int dns_resource_key_from_json(sd_json_variant *v, DnsResourceKey **ret) { - _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; - uint16_t type = 0, class = 0; - const char *name = NULL; - int r; + struct params { + uint16_t type; + uint16_t class; + const char *name; + }; - sd_json_dispatch_field dispatch_table[] = { - { "class", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, PTR_TO_SIZE(&class), SD_JSON_MANDATORY }, - { "type", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, PTR_TO_SIZE(&type), SD_JSON_MANDATORY }, - { "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, PTR_TO_SIZE(&name), SD_JSON_MANDATORY }, + static const sd_json_dispatch_field dispatch_table[] = { + { "class", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, offsetof(struct params, class), SD_JSON_MANDATORY }, + { "type", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint16, offsetof(struct params, type), SD_JSON_MANDATORY }, + { "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(struct params, name), SD_JSON_MANDATORY }, {} }; + _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; + struct params p; + int r; + assert(v); assert(ret); - r = sd_json_dispatch(v, dispatch_table, 0, NULL); + r = sd_json_dispatch(v, dispatch_table, 0, &p); if (r < 0) return r; - key = dns_resource_key_new(class, type, name); + key = dns_resource_key_new(p.class, p.type, p.name); if (!key) return -ENOMEM; |