elf-util: reduce variable scope

This commit is contained in:
Yu Watanabe
2022-01-04 04:27:11 +09:00
parent d090049c01
commit fe8fdc4760
+3 -3
View File
@@ -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);