diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-01-03 17:55:32 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-01-03 20:27:11 +0100 |
commit | fe8fdc47600126d52b4d53d2af8f4606fc94e000 (patch) | |
tree | ea8ab8520f0920361be9dee4bbf52b5e7432dfa4 | |
parent | elf-util: executable argument for parse_elf() may be NULL (diff) | |
download | systemd-fe8fdc47600126d52b4d53d2af8f4606fc94e000.tar.xz systemd-fe8fdc47600126d52b4d53d2af8f4606fc94e000.zip |
elf-util: reduce variable scope
-rw-r--r-- | src/shared/elf-util.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c index 7a62a8088e..32335f9cdb 100644 --- a/src/shared/elf-util.c +++ b/src/shared/elf-util.c @@ -577,7 +577,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r .package_metadata = &package_metadata, .modules = &modules, }; - const char *elf_architecture = NULL, *elf_type; + const char *elf_type; GElf_Ehdr elf_header; size_t sz = 0; int r; @@ -646,8 +646,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r return log_warning_errno(r, "Failed to build JSON object: %m"); #if HAVE_DWELF_ELF_E_MACHINE_STRING - elf_architecture = sym_dwelf_elf_e_machine_string(elf_header.e_machine); -#endif + const char *elf_architecture = sym_dwelf_elf_e_machine_string(elf_header.e_machine); if (elf_architecture) { _cleanup_(json_variant_unrefp) JsonVariant *json_architecture = NULL; @@ -663,6 +662,7 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r if (ret) fprintf(c.f, "ELF object binary architecture: %s\n", elf_architecture); } +#endif /* We always at least have the ELF type, so merge that (and possibly the arch). */ r = json_variant_merge(&elf_metadata, package_metadata); |