]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
elf-util: prefer using SD_JSON_BUILD_PAIR_* macros 39732/head
authorJelle van der Waa <jelle@vdwaa.nl>
Fri, 14 Nov 2025 14:47:15 +0000 (15:47 +0100)
committerJelle van der Waa <jelle@vdwaa.nl>
Fri, 14 Nov 2025 14:47:15 +0000 (15:47 +0100)
No functional change, just refactoring.

src/shared/elf-util.c

index 25fb217149e264ff2f021d7e621e0e3f4ba3dd91..a8cfb8cd22cb4e9c48f91969b629d5ecc1d14862 100644 (file)
@@ -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");