diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-11-07 14:17:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-11-07 14:25:40 +0100 |
commit | 9942f855a920c2bf56b61749193dba46d514dbbb (patch) | |
tree | f3dfaf89048956f7012e19298e2ddadc84acb205 /src/resolve/resolved-varlink.c | |
parent | json: teach dispatch logic to also take numbers formatted as strings (diff) | |
download | systemd-9942f855a920c2bf56b61749193dba46d514dbbb.tar.xz systemd-9942f855a920c2bf56b61749193dba46d514dbbb.zip |
tree-wide: take in all *our* JSON structures also decimal strings
Let's be friendly in what we accept: whenever we define a JSON
structure, let's also allow decimal strings where we want an integer.
This patch purely replaces JSON_VARIANT_UNSIGNED by
_JSON_VARIANT_TYPE_INVALID in the various JsonDispatch[] tables, so that
we'll happily accept any type in json_dispatch(), so that
json_dispatch_uint64() and related tools can do their thing.
This does not switch over OCI (as a JSON structure not defined by us).
Diffstat (limited to 'src/resolve/resolved-varlink.c')
-rw-r--r-- | src/resolve/resolved-varlink.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c index d0953f5d09..3e178a69f3 100644 --- a/src/resolve/resolved-varlink.c +++ b/src/resolve/resolved-varlink.c @@ -292,10 +292,10 @@ static int parse_as_address(Varlink *link, LookupParameters *p) { static int vl_method_resolve_hostname(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) { static const JsonDispatch dispatch_table[] = { - { "ifindex", JSON_VARIANT_UNSIGNED, json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, - { "name", JSON_VARIANT_STRING, json_dispatch_string, offsetof(LookupParameters, name), JSON_MANDATORY }, - { "family", JSON_VARIANT_UNSIGNED, json_dispatch_int, offsetof(LookupParameters, family), 0 }, - { "flags", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(LookupParameters, flags), 0 }, + { "ifindex", _JSON_VARIANT_TYPE_INVALID, json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, + { "name", JSON_VARIANT_STRING, json_dispatch_string, offsetof(LookupParameters, name), JSON_MANDATORY }, + { "family", _JSON_VARIANT_TYPE_INVALID, json_dispatch_int, offsetof(LookupParameters, family), 0 }, + { "flags", _JSON_VARIANT_TYPE_INVALID, json_dispatch_uint64, offsetof(LookupParameters, flags), 0 }, {} }; @@ -468,10 +468,10 @@ finish: static int vl_method_resolve_address(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) { static const JsonDispatch dispatch_table[] = { - { "ifindex", JSON_VARIANT_UNSIGNED, json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, - { "family", JSON_VARIANT_UNSIGNED, json_dispatch_int, offsetof(LookupParameters, family), JSON_MANDATORY }, - { "address", JSON_VARIANT_ARRAY, json_dispatch_address, 0, JSON_MANDATORY }, - { "flags", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(LookupParameters, flags), 0 }, + { "ifindex", _JSON_VARIANT_TYPE_INVALID, json_dispatch_int, offsetof(LookupParameters, ifindex), 0 }, + { "family", _JSON_VARIANT_TYPE_INVALID, json_dispatch_int, offsetof(LookupParameters, family), JSON_MANDATORY }, + { "address", JSON_VARIANT_ARRAY, json_dispatch_address, 0, JSON_MANDATORY }, + { "flags", _JSON_VARIANT_TYPE_INVALID, json_dispatch_uint64, offsetof(LookupParameters, flags), 0 }, {} }; |