]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
authorJelle van der Waa <jelle@vdwaa.nl>
Sat, 22 Nov 2025 13:43:03 +0000 (14:43 +0100)
committerJelle van der Waa <jelle@vdwaa.nl>
Mon, 24 Nov 2025 19:44:14 +0000 (20:44 +0100)
No functional change, just refactoring.

src/core/varlink-dynamic-user.c
src/core/varlink-execute.c
src/core/varlink.c

index 685ed8bac5cc4a785aeb5cc0d01fee75fb33e1e1..d614c0adf9ffb2f8555ea97da54ca7e0ebba59be 100644 (file)
@@ -26,13 +26,13 @@ static int build_user_json(const char *user_name, uid_t uid, sd_json_variant **r
         assert(ret);
 
         return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
-                                       SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
-                                       SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
-                                       SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(uid)),
+                                       SD_JSON_BUILD_PAIR_STRING("userName", user_name),
+                                       SD_JSON_BUILD_PAIR_UNSIGNED("uid", uid),
+                                       SD_JSON_BUILD_PAIR_UNSIGNED("gid", uid),
                                        SD_JSON_BUILD_PAIR("realName", JSON_BUILD_CONST_STRING("Dynamic User")),
                                        SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
                                        SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
-                                       SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
+                                       SD_JSON_BUILD_PAIR_BOOLEAN("locked", true),
                                        SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
                                        SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))));
 }
@@ -136,9 +136,9 @@ static int build_group_json(const char *group_name, gid_t gid, sd_json_variant *
         assert(ret);
 
         return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
-                                       SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)),
+                                       SD_JSON_BUILD_PAIR_STRING("groupName", group_name),
                                        SD_JSON_BUILD_PAIR("description", JSON_BUILD_CONST_STRING("Dynamic Group")),
-                                       SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)),
+                                       SD_JSON_BUILD_PAIR_UNSIGNED("gid", gid),
                                        SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
                                        SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))));
 }
index 116d77e006d81969049cb91afe3c15667c4ff168..afba470e468dcc7554a9aa136b612e781126f27f 100644 (file)
@@ -365,7 +365,7 @@ static int exec_dir_build_json(sd_json_variant **ret, const char *name, void *us
 
         return sd_json_buildo(
                         ret,
-                        SD_JSON_BUILD_PAIR("paths", SD_JSON_BUILD_VARIANT(v)),
+                        SD_JSON_BUILD_PAIR_VARIANT("paths", v),
                         SD_JSON_BUILD_PAIR_UNSIGNED("mode", exec_dir->mode),
                         SD_JSON_BUILD_PAIR("quota",
                                 SD_JSON_BUILD_OBJECT(
index 99f12c59e562f956c136ac58bd9d6986e20b8430..d133b6a640e4461b3379d361cc37ffaf627ed82d 100644 (file)
@@ -61,9 +61,9 @@ static int build_managed_oom_json_array_element(Unit *u, const char *property, s
                 return -EINVAL;
 
         return sd_json_buildo(ret_v,
-                              SD_JSON_BUILD_PAIR("mode", SD_JSON_BUILD_STRING(mode)),
-                              SD_JSON_BUILD_PAIR("path", SD_JSON_BUILD_STRING(crt->cgroup_path)),
-                              SD_JSON_BUILD_PAIR("property", SD_JSON_BUILD_STRING(property)),
+                              SD_JSON_BUILD_PAIR_STRING("mode", mode),
+                              SD_JSON_BUILD_PAIR_STRING("path", crt->cgroup_path),
+                              SD_JSON_BUILD_PAIR_STRING("property", property),
                               SD_JSON_BUILD_PAIR_CONDITION(use_limit, "limit", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit)),
                               SD_JSON_BUILD_PAIR_CONDITION(use_duration, "duration", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_duration_usec)));
 }
@@ -126,7 +126,7 @@ static int build_managed_oom_cgroups_json(Manager *m, bool allow_empty, sd_json_
                 return 0;
         }
 
-        r = sd_json_buildo(ret, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr)));
+        r = sd_json_buildo(ret, SD_JSON_BUILD_PAIR_VARIANT("cgroups", arr));
         if (r < 0)
                 return r;
 
@@ -281,7 +281,7 @@ int manager_varlink_send_managed_oom_update(Unit *u) {
                 return 0;
         }
 
-        r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr)));
+        r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR_VARIANT("cgroups", arr));
         if (r < 0)
                 return r;