From 8ef5e56f977482ab8eb95e86ea1a9ec779f37391 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 14 Nov 2025 13:54:31 +0100 Subject: [PATCH 1/4] sd-json: prefer using SD_JSON_BUILD_PAIR_UNSIGNED No functional change, just refactoring. --- src/libsystemd/sd-json/sd-json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-json/sd-json.c b/src/libsystemd/sd-json/sd-json.c index e6f30bd4aa..295f30ff15 100644 --- a/src/libsystemd/sd-json/sd-json.c +++ b/src/libsystemd/sd-json/sd-json.c @@ -4148,8 +4148,8 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) { if (dual_timestamp_is_set(ts)) { r = sd_json_buildo( &add, - SD_JSON_BUILD_PAIR("realtime", SD_JSON_BUILD_UNSIGNED(ts->realtime)), - SD_JSON_BUILD_PAIR("monotonic", SD_JSON_BUILD_UNSIGNED(ts->monotonic))); + SD_JSON_BUILD_PAIR_UNSIGNED("realtime", ts->realtime), + SD_JSON_BUILD_PAIR_UNSIGNED("monotonic", ts->monotonic)); if (r < 0) goto finish; } else From 7e5d718046546eb0ca32d39063b362660fb249d4 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 14 Nov 2025 13:56:22 +0100 Subject: [PATCH 2/4] userdb: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR( No functional change, just refactoring. --- src/userdb/userdbctl.c | 4 ++-- src/userdb/userwork.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 823b68e7d9..c0df726fe4 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -918,8 +918,8 @@ static int show_membership(const char *user, const char *group, Table *table) { r = sd_json_buildo( &v, - SD_JSON_BUILD_PAIR("user", SD_JSON_BUILD_STRING(user)), - SD_JSON_BUILD_PAIR("group", SD_JSON_BUILD_STRING(group))); + SD_JSON_BUILD_PAIR_STRING("user", user), + SD_JSON_BUILD_PAIR_STRING("group", group)); if (r < 0) return log_error_errno(r, "Failed to build JSON object: %m"); diff --git a/src/userdb/userwork.c b/src/userdb/userwork.c index fc698e841d..ae927bb528 100644 --- a/src/userdb/userwork.c +++ b/src/userdb/userwork.c @@ -119,8 +119,8 @@ static int build_user_json(sd_varlink *link, UserRecord *ur, sd_json_variant **r return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)), - SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete))); + SD_JSON_BUILD_PAIR_VARIANT("record", v), + SD_JSON_BUILD_PAIR_BOOLEAN("incomplete", stripped->incomplete)); } static int userdb_flags_from_service(sd_varlink *link, const char *service, UserDBFlags *ret) { @@ -280,8 +280,8 @@ static int build_group_json(sd_varlink *link, GroupRecord *gr, sd_json_variant * return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)), - SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete))); + SD_JSON_BUILD_PAIR_VARIANT("record", v), + SD_JSON_BUILD_PAIR_BOOLEAN("incomplete", stripped->incomplete)); } static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { @@ -437,8 +437,8 @@ static int vl_method_get_memberships(sd_varlink *link, sd_json_variant *paramete r = sd_varlink_notifybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))); + SD_JSON_BUILD_PAIR_STRING("userName", last_user_name), + SD_JSON_BUILD_PAIR_STRING("groupName", last_group_name)); if (r < 0) return r; } @@ -456,8 +456,8 @@ static int vl_method_get_memberships(sd_varlink *link, sd_json_variant *paramete return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))); + SD_JSON_BUILD_PAIR_STRING("userName", last_user_name), + SD_JSON_BUILD_PAIR_STRING("groupName", last_group_name)); } static int process_connection(sd_varlink_server *server, int _fd) { From 1b636f1d3f8ac8b4378d947b6a8eb07a82090859 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 14 Nov 2025 15:43:30 +0100 Subject: [PATCH 3/4] ssh-generator: prefer using SD_JSON_BUILD_PAIR_STRING No functional change, just refactoring. --- src/ssh-generator/ssh-proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssh-generator/ssh-proxy.c b/src/ssh-generator/ssh-proxy.c index fcdc40c09d..30d5a7eed7 100644 --- a/src/ssh-generator/ssh-proxy.c +++ b/src/ssh-generator/ssh-proxy.c @@ -158,7 +158,7 @@ static int fetch_machine(const char *machine, RuntimeScope scope, sd_json_varian "io.systemd.Machine.List", &result, &error_id, - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(machine))); + SD_JSON_BUILD_PAIR_STRING("name", machine)); if (r < 0) return log_error_errno(r, "Failed to issue io.systemd.Machine.List() varlink call: %m"); if (error_id) { From 887db52362cfb30af9f6b93da9a33225cc45ca2f Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 14 Nov 2025 15:47:15 +0100 Subject: [PATCH 4/4] elf-util: prefer using SD_JSON_BUILD_PAIR_* macros No functional change, just refactoring. --- src/shared/elf-util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c index 25fb217149..a8cfb8cd22 100644 --- a/src/shared/elf-util.c +++ b/src/shared/elf-util.c @@ -448,7 +448,7 @@ static int parse_metadata(const char *name, sd_json_variant *id_json, Elf *elf, /* Then we build a new object using the module name as the key, and merge it * with the previous parses, so that in the end it all fits together in a single * JSON blob. */ - r = sd_json_buildo(&w, SD_JSON_BUILD_PAIR(name, SD_JSON_BUILD_VARIANT(v))); + r = sd_json_buildo(&w, SD_JSON_BUILD_PAIR_VARIANT(name, v)); if (r < 0) return log_error_errno(r, "Failed to build JSON object: %m"); @@ -513,7 +513,7 @@ static int parse_buildid(Dwfl_Module *mod, Elf *elf, const char *name, StackCont /* We will later parse package metadata json and pass it to our caller. Prepare the * build-id in json format too, so that it can be appended and parsed cleanly. It * will then be added as metadata to the journal message with the stack trace. */ - r = sd_json_buildo(&id_json, SD_JSON_BUILD_PAIR("buildId", SD_JSON_BUILD_HEX(id, id_len))); + r = sd_json_buildo(&id_json, SD_JSON_BUILD_PAIR_HEX("buildId", id, id_len)); if (r < 0) return log_error_errno(r, "json_build on buildId failed: %m"); } @@ -756,7 +756,7 @@ static int parse_elf( /* If we found a build-id and nothing else, return at least that. */ if (!package_metadata && id_json) { - r = sd_json_buildo(&package_metadata, SD_JSON_BUILD_PAIR(e, SD_JSON_BUILD_VARIANT(id_json))); + r = sd_json_buildo(&package_metadata, SD_JSON_BUILD_PAIR_VARIANT(e, id_json)); if (r < 0) return log_warning_errno(r, "Failed to build JSON object: %m"); } @@ -769,7 +769,7 @@ static int parse_elf( /* Note that e_type is always DYN for both executables and libraries, so we can't tell them apart from the header, * but we will search for the PT_INTERP section when parsing the metadata. */ - r = sd_json_buildo(&elf_metadata, SD_JSON_BUILD_PAIR("elfType", SD_JSON_BUILD_STRING(elf_type))); + r = sd_json_buildo(&elf_metadata, SD_JSON_BUILD_PAIR_STRING("elfType", elf_type)); if (r < 0) return log_warning_errno(r, "Failed to build JSON object: %m"); @@ -778,7 +778,7 @@ static int parse_elf( if (elf_architecture) { r = sd_json_variant_merge_objectbo( &elf_metadata, - SD_JSON_BUILD_PAIR("elfArchitecture", SD_JSON_BUILD_STRING(elf_architecture))); + SD_JSON_BUILD_PAIR_STRING("elfArchitecture", elf_architecture)); if (r < 0) return log_warning_errno(r, "Failed to add elfArchitecture field: %m");