diff options
author | David Tardon <dtardon@redhat.com> | 2022-11-11 09:53:10 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-11-13 20:22:34 +0900 |
commit | 9c1b0927d3611750a5841906142a784bcc11af23 (patch) | |
tree | 967680efbedb83af59f72da78c07117ed2da8f9a /src | |
parent | 9e1344850fbb33cf8c084ab3042b95815fa43aa6 (diff) | |
download | systemd-9c1b0927d3611750a5841906142a784bcc11af23.tar.gz |
analyze-inspect-elf: port to vertical table
Diffstat (limited to 'src')
-rw-r--r-- | src/analyze/analyze-inspect-elf.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/analyze/analyze-inspect-elf.c b/src/analyze/analyze-inspect-elf.c index 155c611c71..da2c64565a 100644 --- a/src/analyze/analyze-inspect-elf.c +++ b/src/analyze/analyze-inspect-elf.c @@ -34,7 +34,7 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { if (r < 0) return log_error_errno(r, "Parsing \"%s\" as ELF object failed: %m", abspath); - t = table_new("", ""); + t = table_new_vertical(); if (!t) return log_oom(); @@ -44,7 +44,7 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { r = table_add_many( t, - TABLE_STRING, "path:", + TABLE_FIELD, "path", TABLE_STRING, abspath); if (r < 0) return table_log_add_error(r); @@ -62,15 +62,9 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { * metadata is parsed recursively in core files, so there might be * multiple modules. */ if (STR_IN_SET(module_name, "elfType", "elfArchitecture")) { - _cleanup_free_ char *suffixed = NULL; - - suffixed = strjoin(module_name, ":"); - if (!suffixed) - return log_oom(); - r = table_add_many( t, - TABLE_STRING, suffixed, + TABLE_FIELD, module_name, TABLE_STRING, json_variant_string(module_json)); if (r < 0) return table_log_add_error(r); @@ -91,7 +85,7 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { if (!streq(abspath, module_name)) { r = table_add_many( t, - TABLE_STRING, "module name:", + TABLE_FIELD, "module name", TABLE_STRING, module_name); if (r < 0) return table_log_add_error(r); @@ -99,15 +93,9 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { JSON_VARIANT_OBJECT_FOREACH(field_name, field, module_json) if (json_variant_is_string(field)) { - _cleanup_free_ char *suffixed = NULL; - - suffixed = strjoin(field_name, ":"); - if (!suffixed) - return log_oom(); - r = table_add_many( t, - TABLE_STRING, suffixed, + TABLE_FIELD, field_name, TABLE_STRING, json_variant_string(field)); if (r < 0) return table_log_add_error(r); @@ -115,8 +103,6 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) { } } if (json_flags & JSON_FORMAT_OFF) { - (void) table_set_header(t, true); - r = table_print(t, NULL); if (r < 0) return table_log_print_error(r); |