]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze-inspect-elf: port to vertical table
authorDavid Tardon <dtardon@redhat.com>
Fri, 11 Nov 2022 08:53:10 +0000 (09:53 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Nov 2022 11:22:34 +0000 (20:22 +0900)
src/analyze/analyze-inspect-elf.c

index 155c611c7176abcff29b025e94683a1bef433f6f..da2c64565a68b3d782ff5be9bd42acd3b25fa917 100644 (file)
@@ -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);