summaryrefslogtreecommitdiffstats
path: root/src
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
parentjson: don't assert() if we add a NULL element via json_variant_set_field() (diff)
downloadsystemd-0cdf6b14a5389fdeb75d67dde42c88de75962956.tar.xz
systemd-0cdf6b14a5389fdeb75d67dde42c88de75962956.zip
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')
-rw-r--r--src/core/core-varlink.c16
-rw-r--r--src/cryptenroll/cryptenroll-fido2.c4
-rw-r--r--src/cryptenroll/cryptenroll-pkcs11.c2
-rw-r--r--src/cryptenroll/cryptenroll-recovery.c2
-rw-r--r--src/home/homectl-recovery-key.c2
-rw-r--r--src/home/homed-home.c2
-rw-r--r--src/home/homework-luks.c2
-rw-r--r--src/home/user-record-util.c4
-rw-r--r--src/machine/machined-varlink.c10
-rw-r--r--src/nspawn/nspawn-bind-user.c4
-rw-r--r--src/shared/json.h1
-rw-r--r--src/shared/tpm2-util.c2
-rw-r--r--src/shared/userdb.c20
-rw-r--r--src/test/test-format-table.c2
-rw-r--r--src/test/test-json.c14
-rw-r--r--src/test/test-varlink.c2
16 files changed, 45 insertions, 44 deletions
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c
index 8c54cc0663..a75f9fb66f 100644
--- a/src/core/core-varlink.c
+++ b/src/core/core-varlink.c
@@ -31,12 +31,12 @@ static int build_user_json(const char *user_name, uid_t uid, JsonVariant **ret)
JSON_BUILD_PAIR("userName", JSON_BUILD_STRING(user_name)),
JSON_BUILD_PAIR("uid", JSON_BUILD_UNSIGNED(uid)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(uid)),
- JSON_BUILD_PAIR("realName", JSON_BUILD_STRING("Dynamic User")),
- JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING("/")),
- JSON_BUILD_PAIR("shell", JSON_BUILD_STRING(NOLOGIN)),
+ JSON_BUILD_PAIR("realName", JSON_BUILD_CONST_STRING("Dynamic User")),
+ JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
+ JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
JSON_BUILD_PAIR("locked", JSON_BUILD_BOOLEAN(true)),
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.DynamicUser")),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("dynamic"))))));
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))));
}
static bool user_match_lookup_parameters(LookupParameters *p, const char *name, uid_t uid) {
@@ -339,10 +339,10 @@ static int build_group_json(const char *group_name, gid_t gid, JsonVariant **ret
return json_build(ret, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("record", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(group_name)),
- JSON_BUILD_PAIR("description", JSON_BUILD_STRING("Dynamic Group")),
+ JSON_BUILD_PAIR("description", JSON_BUILD_CONST_STRING("Dynamic Group")),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(gid)),
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.DynamicUser")),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("dynamic"))))));
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))));
}
static bool group_match_lookup_parameters(LookupParameters *p, const char *name, gid_t gid) {
diff --git a/src/cryptenroll/cryptenroll-fido2.c b/src/cryptenroll/cryptenroll-fido2.c
index fbf76ee586..dd10b31825 100644
--- a/src/cryptenroll/cryptenroll-fido2.c
+++ b/src/cryptenroll/cryptenroll-fido2.c
@@ -74,11 +74,11 @@ int enroll_fido2(
r = json_build(&v,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("systemd-fido2")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-fido2")),
JSON_BUILD_PAIR("keyslots", JSON_BUILD_ARRAY(JSON_BUILD_STRING(keyslot_as_string))),
JSON_BUILD_PAIR("fido2-credential", JSON_BUILD_BASE64(cid, cid_size)),
JSON_BUILD_PAIR("fido2-salt", JSON_BUILD_BASE64(salt, salt_size)),
- JSON_BUILD_PAIR("fido2-rp", JSON_BUILD_STRING("io.systemd.cryptsetup")),
+ JSON_BUILD_PAIR("fido2-rp", JSON_BUILD_CONST_STRING("io.systemd.cryptsetup")),
JSON_BUILD_PAIR("fido2-clientPin-required", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))),
JSON_BUILD_PAIR("fido2-up-required", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
JSON_BUILD_PAIR("fido2-uv-required", JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV)))));
diff --git a/src/cryptenroll/cryptenroll-pkcs11.c b/src/cryptenroll/cryptenroll-pkcs11.c
index 15ae6c9420..eb098ce6f0 100644
--- a/src/cryptenroll/cryptenroll-pkcs11.c
+++ b/src/cryptenroll/cryptenroll-pkcs11.c
@@ -83,7 +83,7 @@ int enroll_pkcs11(
r = json_build(&v,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("systemd-pkcs11")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-pkcs11")),
JSON_BUILD_PAIR("keyslots", JSON_BUILD_ARRAY(JSON_BUILD_STRING(keyslot_as_string))),
JSON_BUILD_PAIR("pkcs11-uri", JSON_BUILD_STRING(uri)),
JSON_BUILD_PAIR("pkcs11-key", JSON_BUILD_BASE64(encrypted_key, encrypted_key_size))));
diff --git a/src/cryptenroll/cryptenroll-recovery.c b/src/cryptenroll/cryptenroll-recovery.c
index 3fed4bcdd2..7c170f2850 100644
--- a/src/cryptenroll/cryptenroll-recovery.c
+++ b/src/cryptenroll/cryptenroll-recovery.c
@@ -76,7 +76,7 @@ int enroll_recovery(
r = json_build(&v,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("systemd-recovery")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-recovery")),
JSON_BUILD_PAIR("keyslots", JSON_BUILD_ARRAY(JSON_BUILD_STRING(keyslot_as_string)))));
if (r < 0) {
log_error_errno(r, "Failed to prepare recovery key JSON token object: %m");
diff --git a/src/home/homectl-recovery-key.c b/src/home/homectl-recovery-key.c
index da1899ae14..ff1ab6820d 100644
--- a/src/home/homectl-recovery-key.c
+++ b/src/home/homectl-recovery-key.c
@@ -19,7 +19,7 @@ static int add_privileged(JsonVariant **v, const char *hashed) {
assert(hashed);
r = json_build(&e, JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("modhex64")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("modhex64")),
JSON_BUILD_PAIR("hashedPassword", JSON_BUILD_STRING(hashed))));
if (r < 0)
return log_error_errno(r, "Failed to build recover key JSON object: %m");
diff --git a/src/home/homed-home.c b/src/home/homed-home.c
index 2453fa31ef..2cc1f8b384 100644
--- a/src/home/homed-home.c
+++ b/src/home/homed-home.c
@@ -2518,7 +2518,7 @@ int home_augment_status(
r = json_build(&status,
JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("state", JSON_BUILD_STRING(home_state_to_string(state))),
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Home")),
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
JSON_BUILD_PAIR_CONDITION(disk_size != UINT64_MAX, "diskSize", JSON_BUILD_UNSIGNED(disk_size)),
JSON_BUILD_PAIR_CONDITION(disk_usage != UINT64_MAX, "diskUsage", JSON_BUILD_UNSIGNED(disk_usage)),
JSON_BUILD_PAIR_CONDITION(disk_free != UINT64_MAX, "diskFree", JSON_BUILD_UNSIGNED(disk_free)),
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index 774d5d4e30..9c008586fc 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -984,7 +984,7 @@ static int format_luks_token_text(
r = json_build(&v,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("systemd-homed")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-homed")),
JSON_BUILD_PAIR("keyslots", JSON_BUILD_EMPTY_ARRAY),
JSON_BUILD_PAIR("record", JSON_BUILD_BASE64(encrypted, encrypted_size_out1 + encrypted_size_out2)),
JSON_BUILD_PAIR("iv", JSON_BUILD_BASE64(iv, iv_size))));
diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c
index 276caaa172..c4746cedc6 100644
--- a/src/home/user-record-util.c
+++ b/src/home/user-record-util.c
@@ -83,7 +83,7 @@ int user_record_synthesize(
JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("userName", JSON_BUILD_STRING(user_name)),
JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(realm)),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("regular")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("regular")),
JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("imagePath", JSON_BUILD_STRING(image_path)),
@@ -150,7 +150,7 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
JSON_BUILD_PAIR("status", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Home"))))))));
+ JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home"))))))));
if (r < 0)
return r;
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) {
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");
diff --git a/src/shared/json.h b/src/shared/json.h
index 0676e7bf5c..2248515ef7 100644
--- a/src/shared/json.h
+++ b/src/shared/json.h
@@ -259,6 +259,7 @@ enum {
#define JSON_BUILD_HEX(p, n) _JSON_BUILD_HEX, (const void*) { p }, (size_t) { n }
#define JSON_BUILD_ID128(id) _JSON_BUILD_ID128, (const sd_id128_t*) { &(id) }
#define JSON_BUILD_BYTE_ARRAY(v, n) _JSON_BUILD_BYTE_ARRAY, (const void*) { v }, (size_t) { n }
+#define JSON_BUILD_CONST_STRING(s) _JSON_BUILD_VARIANT, JSON_VARIANT_STRING_CONST(s)
int json_build(JsonVariant **ret, ...);
int json_buildv(JsonVariant **ret, va_list ap);
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index 6a84d23db6..70a2929432 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -1257,7 +1257,7 @@ int tpm2_make_luks2_json(
r = json_build(&v,
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("type", JSON_BUILD_STRING("systemd-tpm2")),
+ JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-tpm2")),
JSON_BUILD_PAIR("keyslots", JSON_BUILD_ARRAY(JSON_BUILD_STRING(keyslot_as_string))),
JSON_BUILD_PAIR("tpm2-blob", JSON_BUILD_BASE64(blob, blob_size)),
JSON_BUILD_PAIR("tpm2-pcrs", JSON_BUILD_VARIANT(a)),
diff --git a/src/shared/userdb.c b/src/shared/userdb.c
index 555c71c82d..5c2b3ddb8f 100644
--- a/src/shared/userdb.c
+++ b/src/shared/userdb.c
@@ -600,22 +600,22 @@ static int userdb_process(
static int synthetic_root_user_build(UserRecord **ret) {
return user_record_build(
ret,
- JSON_BUILD_OBJECT(JSON_BUILD_PAIR("userName", JSON_BUILD_STRING("root")),
+ JSON_BUILD_OBJECT(JSON_BUILD_PAIR("userName", JSON_BUILD_CONST_STRING("root")),
JSON_BUILD_PAIR("uid", JSON_BUILD_UNSIGNED(0)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(0)),
- JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING("/root")),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("intrinsic"))));
+ JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/root")),
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))));
}
static int synthetic_nobody_user_build(UserRecord **ret) {
return user_record_build(
ret,
- JSON_BUILD_OBJECT(JSON_BUILD_PAIR("userName", JSON_BUILD_STRING(NOBODY_USER_NAME)),
+ JSON_BUILD_OBJECT(JSON_BUILD_PAIR("userName", JSON_BUILD_CONST_STRING(NOBODY_USER_NAME)),
JSON_BUILD_PAIR("uid", JSON_BUILD_UNSIGNED(UID_NOBODY)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(GID_NOBODY)),
- JSON_BUILD_PAIR("shell", JSON_BUILD_STRING(NOLOGIN)),
+ JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
JSON_BUILD_PAIR("locked", JSON_BUILD_BOOLEAN(true)),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("intrinsic"))));
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))));
}
int userdb_by_name(const char *name, UserDBFlags flags, UserRecord **ret) {
@@ -878,17 +878,17 @@ int userdb_iterator_get(UserDBIterator *iterator, UserRecord **ret) {
static int synthetic_root_group_build(GroupRecord **ret) {
return group_record_build(
ret,
- JSON_BUILD_OBJECT(JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING("root")),
+ JSON_BUILD_OBJECT(JSON_BUILD_PAIR("groupName", JSON_BUILD_CONST_STRING("root")),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(0)),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("intrinsic"))));
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))));
}
static int synthetic_nobody_group_build(GroupRecord **ret) {
return group_record_build(
ret,
- JSON_BUILD_OBJECT(JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(NOBODY_GROUP_NAME)),
+ JSON_BUILD_OBJECT(JSON_BUILD_PAIR("groupName", JSON_BUILD_CONST_STRING(NOBODY_GROUP_NAME)),
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(GID_NOBODY)),
- JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("intrinsic"))));
+ JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))));
}
int groupdb_by_name(const char *name, UserDBFlags flags, GroupRecord **ret) {
diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c
index ea96e22391..7a4c98eba6 100644
--- a/src/test/test-format-table.c
+++ b/src/test/test-format-table.c
@@ -390,7 +390,7 @@ static void test_json(void) {
assert_se(json_build(&w,
JSON_BUILD_ARRAY(
JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("foo_bar", JSON_BUILD_STRING("v1")),
+ JSON_BUILD_PAIR("foo_bar", JSON_BUILD_CONST_STRING("v1")),
JSON_BUILD_PAIR("quux", JSON_BUILD_UNSIGNED(4711)),
JSON_BUILD_PAIR("zzz", JSON_BUILD_BOOLEAN(true))),
JSON_BUILD_OBJECT(
diff --git a/src/test/test-json.c b/src/test/test-json.c
index d1d551e746..926b246e17 100644
--- a/src/test/test-json.c
+++ b/src/test/test-json.c
@@ -333,16 +333,16 @@ static void test_build(void) {
assert_se(json_build(&a, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("x", JSON_BUILD_STRING("y")),
- JSON_BUILD_PAIR("z", JSON_BUILD_STRING("a")),
- JSON_BUILD_PAIR("b", JSON_BUILD_STRING("c"))
+ JSON_BUILD_PAIR("z", JSON_BUILD_CONST_STRING("a")),
+ JSON_BUILD_PAIR("b", JSON_BUILD_CONST_STRING("c"))
)) >= 0);
assert_se(json_build(&b, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("x", JSON_BUILD_STRING("y")),
JSON_BUILD_PAIR_CONDITION(false, "p", JSON_BUILD_STRING("q")),
- JSON_BUILD_PAIR_CONDITION(true, "z", JSON_BUILD_STRING("a")),
- JSON_BUILD_PAIR_CONDITION(false, "j", JSON_BUILD_ARRAY(JSON_BUILD_STRING("k"), JSON_BUILD_STRING("u"), JSON_BUILD_STRING("i"))),
- JSON_BUILD_PAIR("b", JSON_BUILD_STRING("c"))
+ JSON_BUILD_PAIR_CONDITION(true, "z", JSON_BUILD_CONST_STRING("a")),
+ JSON_BUILD_PAIR_CONDITION(false, "j", JSON_BUILD_ARRAY(JSON_BUILD_STRING("k"), JSON_BUILD_CONST_STRING("u"), JSON_BUILD_CONST_STRING("i"))),
+ JSON_BUILD_PAIR("b", JSON_BUILD_CONST_STRING("c"))
)) >= 0);
assert_se(json_variant_equal(a, b));
@@ -435,8 +435,8 @@ static void test_normalize(void) {
assert_se(json_build(&v, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("b", JSON_BUILD_STRING("x")),
- JSON_BUILD_PAIR("c", JSON_BUILD_STRING("y")),
- JSON_BUILD_PAIR("a", JSON_BUILD_STRING("z")))) >= 0);
+ JSON_BUILD_PAIR("c", JSON_BUILD_CONST_STRING("y")),
+ JSON_BUILD_PAIR("a", JSON_BUILD_CONST_STRING("z")))) >= 0);
assert_se(!json_variant_is_sorted(v));
assert_se(!json_variant_is_normalized(v));
diff --git a/src/test/test-varlink.c b/src/test/test-varlink.c
index d442b8b5f1..634baf1ae8 100644
--- a/src/test/test-varlink.c
+++ b/src/test/test-varlink.c
@@ -126,7 +126,7 @@ static void flood_test(const char *address) {
assert_se(varlink_set_description(c, "overload-client") >= 0);
assert_se(varlink_attach_event(c, e, k) >= 0);
assert_se(varlink_bind_reply(c, overload_reply) >= 0);
- assert_se(varlink_invokeb(c, "io.test.Overload", JSON_BUILD_OBJECT(JSON_BUILD_PAIR("foo", JSON_BUILD_STRING("bar")))) >= 0);
+ assert_se(varlink_invokeb(c, "io.test.Overload", JSON_BUILD_OBJECT(JSON_BUILD_PAIR("foo", JSON_BUILD_CONST_STRING("bar")))) >= 0);
/* Unblock it */
log_debug("Unblocking server...");