From patchwork Fri Jun 1 07:30:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137465 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp606142lji; Fri, 1 Jun 2018 00:35:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJY05qEeZY/O5+4h9snF+dgvOOA0qObEvdr75dWdRjJvEfzLsPJVjZd3+U6mcV36FaT8IIr X-Received: by 2002:a37:8202:: with SMTP id e2-v6mr9066608qkd.443.1527838500494; Fri, 01 Jun 2018 00:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838500; cv=none; d=google.com; s=arc-20160816; b=vCBUHBST4YwJkPDlYQbUhMzgY6mWYxmIxPxwBEo6jUHlhMXOvXHYZ4eEuvQFql6PZT ewOMHtrqoB2FGLP7LCBnvTaERvzkZkEdJct9NQ5py2zLON0U3XqZ4iP5WD8KLTy/TLLK bB2Sq4w6VV4xu9C+9TnQecs1tipj5922KKMPTx5h62uWuMjaOz68NPcKHknD6EnD70wE 8DcndjXwBsWm2mGdeM3Aa+LPkFf2ua+2pv8oK4m9vUUqTj/4DePB205TOztEecEbCFNv HVcuvKM9k0nZSIdBhVqgURUR/ZSTUfN0VAXpiHjuQgHLE5M7fiBP2Vr4CIhPOIvpEW48 TA5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=aWl8x06HutQqYX7aa+Ia2FNpn0qsK+sqgsx3vcYEnfDOI5JFpUbf3ZXfMc5skBm6yb u6Z+hifQFVm7k9aIjXYi4ruQbIcVhaZy8VR2kJcNBmS4sNjCn1Wg/hbzgrhg2rSJ2QGx 1zVF++nDN1i06Ntigp/z/5xsL7vsBb8Zu2Kj/EkSN174ZoSzaHh1PBXfm/8WUd9LUJDv sUU/Rx84CrH4uovIQTEUXPU7DKe3xlrU6OKvRWaoaesha0CvMNUCDwnCPvPG0d7i47p/ frFjMtjLemMS2R2Sr+ZtafsRHf8nN8urGzyRPU1SMnX2mcZQ1igb/Lf4ooRohO4avmi4 NXqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MbVVW7DO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d14-v6si2709873qtb.70.2018.06.01.00.35.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:35:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MbVVW7DO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeaR-0007vG-U3 for patch@linaro.org; Fri, 01 Jun 2018 03:34:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005Si-Fw for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWf-0000Jq-1S for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWe-0000JJ-Q8 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:04 -0400 Received: by mail-pg0-x244.google.com with SMTP id w12-v6so9663034pgc.6 for ; Fri, 01 Jun 2018 00:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=MbVVW7DOX2TKxXhsDjQIQ1iY8ekvSvVo0tEtZ9jLWOuIhTi/Qm4fwEju4mANbaJty2 zVe1XKliwGZyAng/eEroJj1MkJxPiMtfxbH8BRmIKaevsOC4bwzt9tf9uTFeFpvdjBkQ rKJ3YUA8lAlMbxUED5PErG4q0Qt8585xe+gRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=XNyA4yH12khLtyZtmSe0lAk6jpWvxloABvH1GOUGhV0JgNWlmrzRHyhM+TQt/7iqn2 lWCFAaWUHpliO1zH2KuMKoBlWXqw+7HjaXfsQgb7UiutfjcNHnjfpocisUUULIyGYRS2 LzzBHE2Nz1nWhDwQBHJTFdJJygdXemkmO36ghS4DnHUDN1Ry4gUrSuZubTNXFjy7qMIq 9dtxkXFUhUqJpENxhKA/XNDBbu9+dC6/lEv8oGzQqugM70/m+dj6iqh1zOJmUyTTLGyF buPOm2O0ynO6uw/c8XplHO+OGIoGRGVPT/BLfrVESGTcudMdcJ66Mvw4SjaQDkN3egVc ctgQ== X-Gm-Message-State: ALKqPwdFgv0Vf8/RUNI4h64rl0nK4nrsSR1ptXEmO6BB8tj7GwQM2fw8 kYNS1fS2lXEbjhN7BWLYYuxSRV8J+rY= X-Received: by 2002:a62:a30e:: with SMTP id s14-v6mr9641176pfe.168.1527838263495; Fri, 01 Jun 2018 00:31:03 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:24 -0700 Message-Id: <20180601073050.8054-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 62 ++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4269ec2c23..a413aad658 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9001,8 +9001,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); @@ -9029,8 +9028,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; @@ -9073,8 +9071,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; @@ -9363,15 +9360,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; } if (contains_hostfd(&rfds) || contains_hostfd(&wfds) || @@ -9409,8 +9406,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); @@ -9951,18 +9947,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; } - ret = 0; if (len == 0) { - return ret; + 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); @@ -10363,8 +10356,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)); @@ -10556,7 +10548,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret < 0) { unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); - goto fail; + return ret; } } @@ -10788,7 +10780,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; @@ -11290,8 +11282,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])); @@ -11552,8 +11543,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); @@ -11601,8 +11591,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]); @@ -11622,8 +11611,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]); @@ -11704,20 +11692,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; @@ -12892,7 +12877,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, default: return do_unimplemented(num); } -fail: return ret; }