diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-25 10:25:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-25 14:22:31 +0100 |
commit | 0cdf6b14a5389fdeb75d67dde42c88de75962956 (patch) | |
tree | d9b3053975fd55469eb8954be7537fe911d2ad6c /src/nspawn | |
parent | e2c7efd3293c6a14cd6d5baf8e0898da9a5c6d96 (diff) | |
download | systemd-0cdf6b14a5389fdeb75d67dde42c88de75962956.tar.gz |
json: add new JSON_BUILD_CONST_STRING() macro
This macro is like JSON_BUILD_STRING() but uses our json library's
ability to use literal strings directly as JsonVariant objects.
The changes all our codebase to use this new macro whenever we build
JSON objects from literal strings.
(I tried to make this automatic, i.e. to detect in JSON_BUILD_STRING()
whether something is a literal string nicely and thus do this stuff
automatically, but I couldn't find a way.)
This should reduce memory usage of our JSON code a bit. Constant strings
we use very often will now be shared and mapped directly from the ELF
image.
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn-bind-user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nspawn/nspawn-bind-user.c b/src/nspawn/nspawn-bind-user.c index a5d866da95..d3113c303e 100644 --- a/src/nspawn/nspawn-bind-user.c +++ b/src/nspawn/nspawn-bind-user.c @@ -128,7 +128,7 @@ static int convert_user( JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(allocate_uid)), JSON_BUILD_PAIR_CONDITION(u->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(u->disposition))), JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING(h)), - JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.NSpawn")), + JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NSpawn")), JSON_BUILD_PAIR_CONDITION(!strv_isempty(u->hashed_password), "privileged", JSON_BUILD_OBJECT( JSON_BUILD_PAIR("hashedPassword", JSON_BUILD_VARIANT(hp)))))); if (r < 0) @@ -140,7 +140,7 @@ static int convert_user( JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(g->group_name)), JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(allocate_uid)), JSON_BUILD_PAIR_CONDITION(g->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(g->disposition))), - JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.NSpawn")))); + JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NSpawn")))); if (r < 0) return log_error_errno(r, "Failed to build container group record: %m"); |