From e89f07d38427dc9e3aab17298d1bc0d339ed3004 Mon Sep 17 00:00:00 2001 From: pbrook Date: Sat, 4 Feb 2006 20:46:24 +0000 Subject: [PATCH] Make target_mmap always return -1 on failure. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1741 c046a42c-6fe2-441c-8c8c-71466251a162 --- linux-user/elfload.c | 2 +- linux-user/mmap.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 29730dca78..c934fb831b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -890,7 +890,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, interpreter_fd, eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr)); - if (error > -1024UL) { + if (error == -1) { /* Real error */ close(interpreter_fd); free(elf_phdata); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index a404ef3b0c..948f2f6b2e 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -183,8 +183,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, } #endif - if (offset & ~TARGET_PAGE_MASK) - return -EINVAL; + if (offset & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } len = TARGET_PAGE_ALIGN(len); if (len == 0) @@ -232,8 +234,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, } } - if (start & ~TARGET_PAGE_MASK) - return -EINVAL; + if (start & ~TARGET_PAGE_MASK) { + errno = EINVAL; + return -1; + } end = start + len; host_end = HOST_PAGE_ALIGN(end); @@ -244,8 +248,10 @@ long target_mmap(unsigned long start, unsigned long len, int prot, /* msync() won't work here, so we return an error if write is possible while it is a shared mapping */ if ((flags & MAP_TYPE) == MAP_SHARED && - (prot & PROT_WRITE)) - return -EINVAL; + (prot & PROT_WRITE)) { + errno = EINVAL; + return -1; + } retaddr = target_mmap(start, len, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -- 2.11.4.GIT