Skip to content

Commit

Permalink
linux-user: Fix do_shmat type errors
Browse files Browse the repository at this point in the history
The guest address, raddr, should be unsigned, aka abi_ulong.
The host addresses should be cast via *intptr_t not long.
Drop the inline and fix two other whitespace issues.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Message-Id: <20230626140250.69572-1-richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jul 15, 2023
1 parent 7a8d9f3 commit 9b61f77
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4539,14 +4539,14 @@ static inline abi_ulong target_shmlba(CPUArchState *cpu_env)
}
#endif

static inline abi_ulong do_shmat(CPUArchState *cpu_env,
int shmid, abi_ulong shmaddr, int shmflg)
static abi_ulong do_shmat(CPUArchState *cpu_env, int shmid,
abi_ulong shmaddr, int shmflg)
{
CPUState *cpu = env_cpu(cpu_env);
abi_long raddr;
abi_ulong raddr;
void *host_raddr;
struct shmid_ds shm_info;
int i,ret;
int i, ret;
abi_ulong shmlba;

/* shmat pointers are always untagged */
Expand Down Expand Up @@ -4602,9 +4602,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env,

if (host_raddr == (void *)-1) {
mmap_unlock();
return get_errno((long)host_raddr);
return get_errno((intptr_t)host_raddr);
}
raddr=h2g((unsigned long)host_raddr);
raddr = h2g((uintptr_t)host_raddr);

page_set_flags(raddr, raddr + shm_info.shm_segsz - 1,
PAGE_VALID | PAGE_RESET | PAGE_READ |
Expand All @@ -4621,7 +4621,6 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env,

mmap_unlock();
return raddr;

}

static inline abi_long do_shmdt(abi_ulong shmaddr)
Expand Down

0 comments on commit 9b61f77

Please sign in to comment.