diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-04-04 16:40:02 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-04-12 13:11:11 +0200 |
commit | 33d60b8d57b0dc9e1a7b700ab5c9060d170247f7 (patch) | |
tree | 453fd25eb056bba26dd840558f79cf0aebcadc4e /src/shared | |
parent | 15de23a0b24f6073d527c6a8c22556ad5101a160 (diff) | |
download | systemd-33d60b8d57b0dc9e1a7b700ab5c9060d170247f7.tar.gz |
json: simplify JSON_VARIANT_OBJECT_FOREACH() macro a bit
There's no point in returning the "key" within each loop iteration as
JsonVariant object. Let's simplify things and return it as string. That
simplifies usage (since the caller doesn't have to convert the object to
the string anymore) and is safe since we already validate that keys are
strings when an object JsonVariant is allocated.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/json.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/json.h b/src/shared/json.h index e5532c506e..675ce2091e 100644 --- a/src/shared/json.h +++ b/src/shared/json.h @@ -143,7 +143,7 @@ struct json_variant_foreach_state { #define JSON_VARIANT_OBJECT_FOREACH(k, e, v) \ for (struct json_variant_foreach_state _state = { (v), 0 }; \ _state.idx < json_variant_elements(_state.variant) && \ - ({ k = json_variant_by_index(_state.variant, _state.idx); \ + ({ k = json_variant_string(json_variant_by_index(_state.variant, _state.idx)); \ e = json_variant_by_index(_state.variant, _state.idx + 1); \ true; }); \ _state.idx += 2) |