core: 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-22 14:43:03 +01:00
parent ab5a79ff5d
commit a751da2cb6
3 changed files with 12 additions and 12 deletions

View 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")))));
}

View 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(

View 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;