diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-11-01 18:01:08 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-11-04 11:42:37 +0100 |
commit | dfaff662a08e97ff2e3ad640594b40c3c5adb82b (patch) | |
tree | 0792f3cc237da3a314818964e5599ee0849fdc5a /src/nss-resolve | |
parent | update TODO (diff) | |
download | systemd-dfaff662a08e97ff2e3ad640594b40c3c5adb82b.tar.xz systemd-dfaff662a08e97ff2e3ad640594b40c3c5adb82b.zip |
json-util: generalize json_dispatch_ifindex()
Let's move the helper from nss-resolve.c to generic code, as it's going
to be useful in #34640.
Also, let's tighten the rules, and refuse negative ifindexes, because
they are invalid.
Diffstat (limited to 'src/nss-resolve')
-rw-r--r-- | src/nss-resolve/nss-resolve.c | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index 91c5f11cb2..1c64ac2fd0 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -96,23 +96,6 @@ static uint32_t ifindex_to_scopeid(int family, const void *a, int ifindex) { return in6_addr_is_link_local(&in6) ? ifindex : 0; } -static int json_dispatch_ifindex(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) { - int *ifi = ASSERT_PTR(userdata); - int64_t t; - - assert(variant); - - if (!sd_json_variant_is_integer(variant)) - return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name)); - - t = sd_json_variant_integer(variant); - if (t > INT_MAX) - return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is out of bounds for an interface index.", strna(name)); - - *ifi = (int) t; - return 0; -} - static int json_dispatch_family(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) { int *family = ASSERT_PTR(userdata); int64_t t; |