From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu
Subject: [Qemu-devel] [PATCH v4 07/16] linux-user: Propagate goto fail to return
Date: Sat, 18 Aug 2018 12:01:09 -0700 [thread overview]
Message-ID: <20180818190118.12911-8-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180818190118.12911-1-richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/syscall.c | 60 ++++++++++++++++----------------------------
1 file changed, 22 insertions(+), 38 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ef3b9b623c..4ae608fb19 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8910,8 +8910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
how = SIG_SETMASK;
break;
default:
- ret = -TARGET_EINVAL;
- goto fail;
+ return -TARGET_EINVAL;
}
mask = arg2;
target_to_host_old_sigset(&set, &mask);
@@ -8938,8 +8937,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
how = SIG_SETMASK;
break;
default:
- ret = -TARGET_EINVAL;
- goto fail;
+ return -TARGET_EINVAL;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
return -TARGET_EFAULT;
@@ -8982,8 +8980,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
how = SIG_SETMASK;
break;
default:
- ret = -TARGET_EINVAL;
- goto fail;
+ return -TARGET_EINVAL;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
return -TARGET_EFAULT;
@@ -9273,15 +9270,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n);
if (ret) {
- goto fail;
+ return ret;
}
ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n);
if (ret) {
- goto fail;
+ return ret;
}
ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n);
if (ret) {
- goto fail;
+ return ret;
}
/*
@@ -9314,8 +9311,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
sig.set = &set;
if (arg_sigsize != sizeof(*target_sigset)) {
/* Like the kernel, we enforce correct size sigsets */
- ret = -TARGET_EINVAL;
- goto fail;
+ return -TARGET_EINVAL;
}
target_sigset = lock_user(VERIFY_READ, arg_sigset,
sizeof(*target_sigset), 1);
@@ -9754,17 +9750,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */
case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */
{
- ret = -TARGET_EINVAL;
if (len < 0) {
- goto fail;
+ return -TARGET_EINVAL;
}
if (len == 0) {
return 0;
}
p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!p) {
- ret = -TARGET_EFAULT;
- goto fail;
+ return -TARGET_EFAULT;
}
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
unlock_user(p, arg2, arg3);
@@ -10109,8 +10103,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
dirp = g_try_malloc(count);
if (!dirp) {
- ret = -TARGET_ENOMEM;
- goto fail;
+ return -TARGET_ENOMEM;
}
ret = get_errno(sys_getdents(arg1, dirp, count));
@@ -10510,7 +10503,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
arg2 ? &node : NULL,
NULL));
if (is_error(ret)) {
- goto fail;
+ return ret;
}
if (arg1 && put_user_u32(cpu, arg1)) {
return -TARGET_EFAULT;
@@ -10966,8 +10959,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1);
if (!target_grouplist) {
- ret = -TARGET_EFAULT;
- goto fail;
+ return -TARGET_EFAULT;
}
for (i = 0; i < gidsetsize; i++) {
grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
@@ -11225,8 +11217,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
how = SIG_SETMASK;
break;
default:
- ret = -TARGET_EINVAL;
- goto fail;
+ return -TARGET_EINVAL;
}
mask = arg2;
target_to_host_old_sigset(&set, &mask);
@@ -11274,8 +11265,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {
- ret = -TARGET_EFAULT;
- goto fail;
+ return -TARGET_EFAULT;
}
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap32(grouplist[i]);
@@ -11295,8 +11285,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
if (!target_grouplist) {
- ret = -TARGET_EFAULT;
- goto fail;
+ return -TARGET_EFAULT;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap32(target_grouplist[i]);
@@ -11371,20 +11360,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_mincore
case TARGET_NR_mincore:
{
- void *a;
- ret = -TARGET_ENOMEM;
- a = lock_user(VERIFY_READ, arg1, arg2, 0);
+ void *a = lock_user(VERIFY_READ, arg1, arg2, 0);
if (!a) {
- goto fail;
+ return -TARGET_ENOMEM;
}
- ret = -TARGET_EFAULT;
p = lock_user_string(arg3);
if (!p) {
- goto mincore_fail;
+ ret = -TARGET_EFAULT;
+ } else {
+ ret = get_errno(mincore(a, arg2, p));
+ unlock_user(p, arg3, ret);
}
- ret = get_errno(mincore(a, arg2, p));
- unlock_user(p, arg3, ret);
- mincore_fail:
unlock_user(a, arg1, 0);
}
return ret;
@@ -11850,8 +11836,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(p = lock_user_string(arg2))) {
- ret = -TARGET_EFAULT;
- goto fail;
+ return -TARGET_EFAULT;
}
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
unlock_user(p, arg2, 0);
@@ -12493,7 +12478,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
return -TARGET_ENOSYS;
}
-fail:
return ret;
}
--
2.17.1
next prev parent reply other threads:[~2018-08-18 19:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-18 19:01 [Qemu-devel] [PATCH v4 00/16] linux-user: Split do_syscall Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 01/16] linux-user: Remove DEBUG Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 02/16] linux-user: Split out do_syscall1 Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 03/16] linux-user: Relax single exit from "break" Richard Henderson
2018-08-21 18:45 ` Philippe Mathieu-Daudé
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 04/16] linux-user: Propagate goto efault to return Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 05/16] linux-user: Propagate goto unimplemented_nowarn " Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 06/16] linux-user: Propagate goto unimplemented to default Richard Henderson
2018-08-21 16:35 ` Laurent Vivier
2018-08-21 18:45 ` Philippe Mathieu-Daudé
2018-08-18 19:01 ` Richard Henderson [this message]
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 08/16] configure: Use -Wunused-const-variable Richard Henderson
2018-08-21 17:29 ` Laurent Vivier
2018-08-21 17:34 ` Laurent Vivier
2018-08-22 1:06 ` Laurent Vivier
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 09/16] linux-user: Setup split syscall infrastructure Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 10/16] linux-user: Split out some simple file syscalls Richard Henderson
2018-08-22 0:50 ` Laurent Vivier
2018-08-22 22:58 ` Richard Henderson
2018-08-23 15:48 ` Laurent Vivier
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 11/16] linux-user: Split out preadv, pwritev, readv, writev Richard Henderson
2018-08-22 16:03 ` Laurent Vivier
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 12/16] linux-user: Split out pread64, pwrite64 Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 13/16] linux-user: Split out name_to_handle_at, open_by_handle_at Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 14/16] linux-user: Split out ipc syscalls Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 15/16] linux-user: Split out memory syscalls Richard Henderson
2018-08-18 19:01 ` [Qemu-devel] [PATCH v4 16/16] linux-user: Split out some process syscalls Richard Henderson
2018-08-21 17:33 ` [Qemu-devel] [PATCH v4 00/16] linux-user: Split do_syscall Laurent Vivier
2018-08-21 17:36 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180818190118.12911-8-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).