]> 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>
Sat, 22 Nov 2025 13:44:15 +0000 (14:44 +0100)
committerJelle van der Waa <jelle@vdwaa.nl>
Mon, 24 Nov 2025 20:05:10 +0000 (21:05 +0100)
No functional change, just refactoring.

src/home/homectl-fido2.c
src/home/homed-varlink.c
src/home/user-record-sign.c

index 41f8f206db1edc8d99fea9a698cd269ee28488be..d351b1db5e113b693554b851a17c4d1af530a6de 100644 (file)
@@ -89,12 +89,12 @@ static int add_fido2_salt(
                 return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m");
 
         r = sd_json_buildo(&e,
-                           SD_JSON_BUILD_PAIR("credential", SD_JSON_BUILD_BASE64(cid, cid_size)),
+                           SD_JSON_BUILD_PAIR_BASE64("credential", cid, cid_size),
                            SD_JSON_BUILD_PAIR("salt", JSON_BUILD_IOVEC_BASE64(salt)),
-                           SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)),
-                           SD_JSON_BUILD_PAIR("up", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
-                           SD_JSON_BUILD_PAIR("uv", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))),
-                           SD_JSON_BUILD_PAIR("clientPin", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))));
+                           SD_JSON_BUILD_PAIR_STRING("hashedPassword", hashed),
+                           SD_JSON_BUILD_PAIR_BOOLEAN("up", FLAGS_SET(lock_with, FIDO2ENROLL_UP)),
+                           SD_JSON_BUILD_PAIR_BOOLEAN("uv", FLAGS_SET(lock_with, FIDO2ENROLL_UV)),
+                           SD_JSON_BUILD_PAIR_BOOLEAN("clientPin", FLAGS_SET(lock_with, FIDO2ENROLL_PIN)));
 
         if (r < 0)
                 return log_error_errno(r, "Failed to build FIDO2 salt JSON key object: %m");
index 9cae051cf9815b5485342293c190c423d2c9b78a..d4015de622e9b37ca99e933d5f853eff7577d911 100644 (file)
@@ -330,8 +330,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_
                         if (last) {
                                 r = sd_varlink_notifybo(
                                                 link,
-                                                SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
-                                                SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
+                                                SD_JSON_BUILD_PAIR_STRING("userName", last),
+                                                SD_JSON_BUILD_PAIR_STRING("groupName", p.group_name));
                                 if (r < 0)
                                         return r;
                         }
@@ -342,8 +342,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_
                 if (last)
                         return sd_varlink_replybo(
                                         link,
-                                        SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
-                                        SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
+                                        SD_JSON_BUILD_PAIR_STRING("userName", last),
+                                        SD_JSON_BUILD_PAIR_STRING("groupName", p.group_name));
         } else {
                 const char *last = NULL;
 
@@ -352,8 +352,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_
                                 if (last) {
                                         r = sd_varlink_notifybo(
                                                         link,
-                                                        SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
-                                                        SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
+                                                        SD_JSON_BUILD_PAIR_STRING("userName", last),
+                                                        SD_JSON_BUILD_PAIR_STRING("groupName", last));
                                         if (r < 0)
                                                 return r;
 
@@ -362,8 +362,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_
 
                                 r = sd_varlink_notifybo(
                                                 link,
-                                                SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
-                                                SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(*j)));
+                                                SD_JSON_BUILD_PAIR_STRING("userName", h->user_name),
+                                                SD_JSON_BUILD_PAIR_STRING("groupName", *j));
                                 if (r < 0)
                                         return r;
                         }
@@ -374,8 +374,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_
                 if (last)
                         return sd_varlink_replybo(
                                         link,
-                                        SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
-                                        SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
+                                        SD_JSON_BUILD_PAIR_STRING("userName", last),
+                                        SD_JSON_BUILD_PAIR_STRING("groupName", last));
         }
 
         return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
index 46e5ea7c992b2b1c3b65bca9fdf966bd05f15fff..7a80ef1e7ab9153f873602cb5e560e43c75fd77c 100644 (file)
@@ -58,8 +58,8 @@ int user_record_sign(UserRecord *ur, EVP_PKEY *private_key, UserRecord **ret) {
                         &v,
                         "signature",
                         SD_JSON_BUILD_ARRAY(
-                                        SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_BASE64(signature, signature_size)),
-                                                             SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_STRING(key)))));
+                                        SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BASE64("data", signature, signature_size),
+                                                             SD_JSON_BUILD_PAIR_STRING("key", key))));
         if (r < 0)
                 return r;