Commit 04d4b0c3 authored by ths's avatar ths
Browse files

Simplify error handling again.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2275 c046a42c-6fe2-441c-8c8c-71466251a162
parent 9042c0e2
...@@ -167,7 +167,7 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend, ...@@ -167,7 +167,7 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
if (!phdr) if (!phdr)
goto fail; goto fail;
if (read(fd, phdr, size) != size) if (read(fd, phdr, size) != size)
goto fail1; goto fail;
if (must_swab) { if (must_swab) {
for(i = 0; i < ehdr.e_phnum; i++) { for(i = 0; i < ehdr.e_phnum; i++) {
ph = &phdr[i]; ph = &phdr[i];
...@@ -184,9 +184,9 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend, ...@@ -184,9 +184,9 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
data = qemu_mallocz(mem_size); data = qemu_mallocz(mem_size);
if (ph->p_filesz > 0) { if (ph->p_filesz > 0) {
if (lseek(fd, ph->p_offset, SEEK_SET) < 0) if (lseek(fd, ph->p_offset, SEEK_SET) < 0)
goto fail2; goto fail;
if (read(fd, data, ph->p_filesz) != ph->p_filesz) if (read(fd, data, ph->p_filesz) != ph->p_filesz)
goto fail2; goto fail;
} }
addr = ph->p_vaddr + virt_to_phys_addend; addr = ph->p_vaddr + virt_to_phys_addend;
...@@ -200,11 +200,8 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend, ...@@ -200,11 +200,8 @@ int glue(load_elf, SZ)(int fd, int64_t virt_to_phys_addend,
} }
qemu_free(phdr); qemu_free(phdr);
return total_size; return total_size;
fail2: fail:
qemu_free(data); qemu_free(data);
fail1:
qemu_free(phdr); qemu_free(phdr);
fail:
return -1; return -1;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment