diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2011-07-04 21:55:56 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2011-07-04 21:55:56 +0000 |
commit | 9cc0dab3ced1f0c9205f6cba4933096eca915157 (patch) | |
tree | fb89bb797c68276935edc26b9a0f21da9dcad712 | |
parent | e06bb54d1210c73e894ae7f1213f9032d22ac2b0 (diff) |
elftosb: remove duplicate code, merge two redundant fields
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30123 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | utils/sbtools/elftosb.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c index 38ac0ae32a..7a0c67e53b 100644 --- a/utils/sbtools/elftosb.c +++ b/utils/sbtools/elftosb.c @@ -184,8 +184,7 @@ struct cmd_source_t struct cmd_source_t *next; /* for later use */ enum cmd_source_type_t type; - bool bin_loaded; - bool elf_loaded; + bool loaded; struct elf_params_t elf; struct bin_param_t bin; }; @@ -683,7 +682,7 @@ static void load_elf_by_id(struct cmd_file_t *cmd_file, const char *id) if(src == NULL) bug("undefined reference to source '%s'\n", id); /* avoid reloading */ - if(src->type == CMD_SRC_ELF && src->elf_loaded) + if(src->type == CMD_SRC_ELF && src->loaded) return; if(src->type != CMD_SRC_UNK) bug("source '%s' seen both as elf and binary file", id); @@ -694,9 +693,9 @@ static void load_elf_by_id(struct cmd_file_t *cmd_file, const char *id) if(g_debug) printf("Loading ELF file '%s'...\n", src->filename); elf_init(&src->elf); - src->elf_loaded = elf_read_file(&src->elf, elf_read, elf_printf, &fd); + src->loaded = elf_read_file(&src->elf, elf_read, elf_printf, &fd); close(fd); - if(!src->elf_loaded) + if(!src->loaded) bug("error loading elf file '%s' (id '%s')\n", src->filename, id); } @@ -705,10 +704,8 @@ static void load_bin_by_id(struct cmd_file_t *cmd_file, const char *id) struct cmd_source_t *src = find_source_by_id(cmd_file, id); if(src == NULL) bug("undefined reference to source '%s'\n", id); - if(src == NULL) - bug("undefined reference to source '%s'\n", id); /* avoid reloading */ - if(src->type == CMD_SRC_BIN && src->bin_loaded) + if(src->type == CMD_SRC_BIN && src->loaded) return; if(src->type != CMD_SRC_UNK) bug("source '%s' seen both as elf and binary file", id); @@ -723,7 +720,7 @@ static void load_bin_by_id(struct cmd_file_t *cmd_file, const char *id) src->bin.data = xmalloc(src->bin.size); read(fd, src->bin.data, src->bin.size); close(fd); - src->bin_loaded = true; + src->loaded = true; } static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file) |