summaryrefslogtreecommitdiff
path: root/src/machine/machined-varlink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-11-25 10:25:03 +0100
committerLennart Poettering <lennart@poettering.net>2021-11-25 14:22:31 +0100
commit0cdf6b14a5389fdeb75d67dde42c88de75962956 (patch)
treed9b3053975fd55469eb8954be7537fe911d2ad6c /src/machine/machined-varlink.c
parente2c7efd3293c6a14cd6d5baf8e0898da9a5c6d96 (diff)
downloadsystemd-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/machine/machined-varlink.c')
-rw-r--r--src/machine/machined-varlink.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/machine/machined-varlink.c b/src/machine/machined-varlink.c
index fc0b0f11ad..6e4fcfda67 100644
--- a/src/machine/machined-varlink.c
+++ b/src/machine/machined-varlink.c
@@ -27,11 +27,11 @@ static int build_user_json(const char *user_name, uid_t uid, const char *real_na
JSON_BUILD_PAIR("uid", JSON_BUILD_UNSIGNED(uid)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(GID_NOBODY)),
JSON_BUILD_PAIR_CONDITION(!isempty(real_name), "realName", JSON_BUILD_STRING(real_name)),
- JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING("/")),
+ JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
JSON_BUILD_PAIR("shell", JSON_BUILD_STRING(NOLOGIN)),
JSON_BUILD_PAIR("locked", JSON_BUILD_BOOLEAN(true)),
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Machine")),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("container"))))));
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))));
}
static bool user_match_lookup_parameters(LookupParameters *p, const char *name, uid_t uid) {
@@ -198,8 +198,8 @@ static int build_group_json(const char *group_name, gid_t gid, const char *descr
JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(group_name)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(gid)),
JSON_BUILD_PAIR_CONDITION(!isempty(description), "description", JSON_BUILD_STRING(description)),
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Machine")),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("container"))))));
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))));
}
static bool group_match_lookup_parameters(LookupParameters *p, const char *name, gid_t gid) {