home: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()

No functional change, just refactoring.
This commit is contained in:
Jelle van der Waa
2025-11-21 17:01:54 +01:00
parent 7dda32a544
commit 2ba6cdc1b9
7 changed files with 20 additions and 20 deletions

View File

@@ -124,9 +124,9 @@ static int add_pkcs11_encrypted_key(
return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m");
r = sd_json_buildo(&e,
SD_JSON_BUILD_PAIR("uri", SD_JSON_BUILD_STRING(uri)),
SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_BASE64(encrypted_key, encrypted_key_size)),
SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)));
SD_JSON_BUILD_PAIR_STRING("uri", uri),
SD_JSON_BUILD_PAIR_BASE64("data", encrypted_key, encrypted_key_size),
SD_JSON_BUILD_PAIR_STRING("hashedPassword", hashed));
if (r < 0)
return log_error_errno(r, "Failed to build encrypted JSON key object: %m");

View File

@@ -20,7 +20,7 @@ static int add_privileged(sd_json_variant **v, const char *hashed) {
assert(hashed);
r = sd_json_buildo(&e, SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("modhex64")),
SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)));
SD_JSON_BUILD_PAIR_STRING("hashedPassword", hashed));
if (r < 0)
return log_error_errno(r, "Failed to build recover key JSON object: %m");

View File

@@ -3805,8 +3805,8 @@ static int parse_argv(int argc, char *argv[]) {
r = sd_json_variant_set_fieldbo(
&arg_identity_extra_rlimits, t,
SD_JSON_BUILD_PAIR("cur", SD_JSON_BUILD_VARIANT(jcur)),
SD_JSON_BUILD_PAIR("max", SD_JSON_BUILD_VARIANT(jmax)));
SD_JSON_BUILD_PAIR_VARIANT("cur", jcur),
SD_JSON_BUILD_PAIR_VARIANT("max", jmax));
if (r < 0)
return log_error_errno(r, "Failed to set %s field: %m", rlimit_to_string(l));

View File

@@ -28,7 +28,7 @@ int bus_message_read_secret(sd_bus_message *m, UserRecord **ret, sd_bus_error *e
if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Failed to parse JSON secret record at %u:%u: %m", line, column);
r = sd_json_buildo(&full, SD_JSON_BUILD_PAIR("secret", SD_JSON_BUILD_VARIANT(v)));
r = sd_json_buildo(&full, SD_JSON_BUILD_PAIR_VARIANT("secret", v));
if (r < 0)
return r;

View File

@@ -2687,7 +2687,7 @@ int home_augment_status(
disk_ceiling = USER_DISK_SIZE_MAX;
r = sd_json_buildo(&status,
SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(home_state_to_string(state))),
SD_JSON_BUILD_PAIR_STRING("state", home_state_to_string(state)),
SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
SD_JSON_BUILD_PAIR("useFallback", SD_JSON_BUILD_BOOLEAN(!HOME_STATE_IS_ACTIVE(state))),
SD_JSON_BUILD_PAIR("fallbackShell", JSON_BUILD_CONST_STRING(BINDIR "/systemd-home-fallback-shell")),

View File

@@ -60,8 +60,8 @@ static int build_user_json(Home *h, bool trusted, sd_json_variant **ret) {
return r;
return sd_json_buildo(ret,
SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(augmented->json)),
SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(augmented->incomplete)));
SD_JSON_BUILD_PAIR_VARIANT("record", augmented->json),
SD_JSON_BUILD_PAIR_BOOLEAN("incomplete", augmented->incomplete));
}
static bool home_user_match_lookup_parameters(LookupParameters *p, Home *h) {
@@ -176,7 +176,7 @@ static int build_group_json(Home *h, sd_json_variant **ret) {
assert(!FLAGS_SET(g->mask, USER_RECORD_SECRET));
assert(!FLAGS_SET(g->mask, USER_RECORD_PRIVILEGED));
return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(g->json)));
return sd_json_buildo(ret, SD_JSON_BUILD_PAIR_VARIANT("record", g->json));
}
static bool home_group_match_lookup_parameters(LookupParameters *p, Home *h) {

View File

@@ -94,16 +94,16 @@ int user_record_synthesize(
r = sd_json_buildo(
&h->json,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
SD_JSON_BUILD_PAIR_STRING("userName", user_name),
SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(realm)),
SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("regular")),
SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("imagePath", SD_JSON_BUILD_STRING(image_path)),
SD_JSON_BUILD_PAIR("homeDirectory", SD_JSON_BUILD_STRING(hd)),
SD_JSON_BUILD_PAIR("storage", SD_JSON_BUILD_STRING(user_storage_to_string(storage))),
SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)))))));
SD_JSON_BUILD_PAIR_STRING("imagePath", image_path),
SD_JSON_BUILD_PAIR_STRING("homeDirectory", hd),
SD_JSON_BUILD_PAIR_STRING("storage", user_storage_to_string(storage)),
SD_JSON_BUILD_PAIR_UNSIGNED("uid", uid),
SD_JSON_BUILD_PAIR_UNSIGNED("gid", gid))))));
if (r < 0)
return r;
@@ -154,9 +154,9 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
r = sd_json_buildo(
&g->json,
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(un)),
SD_JSON_BUILD_PAIR_STRING("groupName", un),
SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(rr)),
SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)),
SD_JSON_BUILD_PAIR_STRING("description", description),
SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
@@ -348,7 +348,7 @@ int user_record_add_binding(
r = sd_json_buildo(
&new_binding_entry,
SD_JSON_BUILD_PAIR("blobDirectory", SD_JSON_BUILD_STRING(blob)),
SD_JSON_BUILD_PAIR_STRING("blobDirectory", blob),
SD_JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", SD_JSON_BUILD_STRING(image_path)),
SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(partition_uuid))),
SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(luks_uuid))),