diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-05-28 14:19:51 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-04 05:35:35 +0200 |
commit | ca5e7694bd10ac59b133e5210d439f2f73793cc9 (patch) | |
tree | f1e4851faf90372308b7b9c9b827a8d5a531da26 /src/shared | |
parent | logind: drop old-style header from .sym file in favour of SPDX (diff) | |
download | systemd-ca5e7694bd10ac59b133e5210d439f2f73793cc9.tar.xz systemd-ca5e7694bd10ac59b133e5210d439f2f73793cc9.zip |
json: use JSON_VARIANT_ARRAY_FOREACH() where we can
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/json.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/shared/json.c b/src/shared/json.c index baea31fed9..a068049b57 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -3407,7 +3407,7 @@ int json_dispatch_string(const char *name, JsonVariant *variant, JsonDispatchFla int json_dispatch_strv(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) { _cleanup_strv_free_ char **l = NULL; char ***s = userdata; - size_t i; + JsonVariant *e; int r; assert(variant); @@ -3421,11 +3421,7 @@ int json_dispatch_strv(const char *name, JsonVariant *variant, JsonDispatchFlags if (!json_variant_is_array(variant)) return json_log(variant, SYNTHETIC_ERRNO(EINVAL), flags, "JSON field '%s' is not an array.", strna(name)); - for (i = 0; i < json_variant_elements(variant); i++) { - JsonVariant *e; - - assert_se(e = json_variant_by_index(variant, i)); - + JSON_VARIANT_ARRAY_FOREACH(e, variant) { if (!json_variant_is_string(e)) return json_log(e, flags, SYNTHETIC_ERRNO(EINVAL), "JSON array element is not a string."); |