From: Jelle van der Waa Date: Fri, 21 Nov 2025 16:01:54 +0000 (+0100) Subject: home: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ba6cdc1b9bcef1705d085ae76e71c534e786b4f;p=thirdparty%2Fsystemd.git home: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR() No functional change, just refactoring. --- diff --git a/src/home/homectl-pkcs11.c b/src/home/homectl-pkcs11.c index 3a0ae306232..a72aecf1356 100644 --- a/src/home/homectl-pkcs11.c +++ b/src/home/homectl-pkcs11.c @@ -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"); diff --git a/src/home/homectl-recovery-key.c b/src/home/homectl-recovery-key.c index b71bf99c335..e6b5a80ce6b 100644 --- a/src/home/homectl-recovery-key.c +++ b/src/home/homectl-recovery-key.c @@ -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"); diff --git a/src/home/homectl.c b/src/home/homectl.c index 1fc888c07fc..15dec438bdb 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -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)); diff --git a/src/home/homed-bus.c b/src/home/homed-bus.c index 2491a887fec..c96ecf66205 100644 --- a/src/home/homed-bus.c +++ b/src/home/homed-bus.c @@ -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; diff --git a/src/home/homed-home.c b/src/home/homed-home.c index 56eb30d08e6..3af3bd09956 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -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")), diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c index a0b8c9c0840..9cae051cf98 100644 --- a/src/home/homed-varlink.c +++ b/src/home/homed-varlink.c @@ -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) { diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c index 3cc100ac946..b15e8f141bc 100644 --- a/src/home/user-record-util.c +++ b/src/home/user-record-util.c @@ -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))),