]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
home: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
authorJelle van der Waa <jelle@vdwaa.nl>
Fri, 21 Nov 2025 16:01:54 +0000 (17:01 +0100)
committerJelle van der Waa <jelle@vdwaa.nl>
Fri, 21 Nov 2025 16:34:57 +0000 (17:34 +0100)
No functional change, just refactoring.

src/home/homectl-pkcs11.c
src/home/homectl-recovery-key.c
src/home/homectl.c
src/home/homed-bus.c
src/home/homed-home.c
src/home/homed-varlink.c
src/home/user-record-util.c

index 3a0ae306232426d8e93f5746c7339f739352fae0..a72aecf1356437ebb512338ec2adbc644d281c7a 100644 (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");
 
index b71bf99c335474128a6256d84428b7a622b9c873..e6b5a80ce6b0285556074ac5a06c93d74d407d6f 100644 (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");
 
index 1fc888c07fc3595ce5b9cf4ad8c531141b4b39bc..15dec438bdb8802056e6f25180162f1f06c9b475 100644 (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));
 
index 2491a887fec5f242d2e7511faaf202942536db21..c96ecf662059b4fec899eea70c5fe715e68a63f9 100644 (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;
 
index 56eb30d08e63f573b76136112648d31fdc89f405..3af3bd099567d66519d0d9a3e3863f4a79e66ad2 100644 (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")),
index a0b8c9c08402586de7de15fb71868b4f2425dca3..9cae051cf9815b5485342293c190c423d2c9b78a 100644 (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) {
index 3cc100ac94639d57d751941c2b04f4104078a083..b15e8f141bc72c242182a3fe412fdfbb33ad9fb1 100644 (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))),