From patchwork Sat Aug 18 19:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 144503 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2204584ljj; Sat, 18 Aug 2018 12:07:54 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz8pCMghGYSGnqXVDPHFpsHNKwuWqcKL/ny3tNXDOYjWN3fPnFFxEmIqskANVpj34qfCwAr X-Received: by 2002:a37:6c07:: with SMTP id h7-v6mr34803362qkc.185.1534619274600; Sat, 18 Aug 2018 12:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534619274; cv=none; d=google.com; s=arc-20160816; b=s7/08eYRKOG4F8AZCUVdgwle1R7wc9CfVAdhVpW76jb8S+GCxhrBBikxOe7cSP15Px j+9w1fdrjpQzWOUS+/Ed9P2AjlL45ga68A90/fKrLD9vaSv5+McftJFuBbhaBSrng0mS jfY1cS/rvTM4VczhxNKt6dTY2Ibr7vjYHhamODe16WQI0WNV8DGoYdkINoENGZXpuJAq SRZvmHRUnS5cKB9RyO0UQxyb06ol0OR+YjnrX9ZefLMJyWm146YM9OFQgB6gsMNOydel 1ytvVh97laImNAxcInu4EhZDsZuWK2b0Kvp7ibs/PfHTnmlJLvA5Hiv/rFYg7TJXDa1m Weiw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=9zkXeR2EX5jvS1lDqF0b0jg60XTfD48rcxo8+2EITsk=; b=0i9D2NWd3LDCnygDlAQiTwQxvSO4CL3VOnn87eEHS0XTyeQjmCUSXEaxYjereqkAV9 lZROvg7cadG7xVI321/H/w2LkmjkBRVW4Sqv+RDYGtm2QFr4Fm6c8J/ZtXgycjJkGks5 M/BwKbeMcsp+GdBGcrm+bKdMMFpnAsFFQ10ddW/QEy4XYjQGq01MzkveTDCcg6RexYwd tWZ8Vdqw0BE5s4wqnJmf1UMr4IVNMuNOOlas6rlfK5j7uitjqz9y+upNxnJbgzc/YDHu /aqOg4F40OK55RSUD5SGJHnuH8PuUbdKJY56MdX8WBiMEl6f8sdMvL09HMTtogIXWLYq OYng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Yvriur9g; 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 r55-v6si3746625qtb.257.2018.08.18.12.07.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 18 Aug 2018 12:07:54 -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=Yvriur9g; 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]:40143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr6Zm-0000vt-0F for patch@linaro.org; Sat, 18 Aug 2018 15:07:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr6Td-0005Gj-CK for qemu-devel@nongnu.org; Sat, 18 Aug 2018 15:01:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fr6Tc-0007B7-91 for qemu-devel@nongnu.org; Sat, 18 Aug 2018 15:01:33 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33500) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fr6Tb-0007Aa-Vy for qemu-devel@nongnu.org; Sat, 18 Aug 2018 15:01:32 -0400 Received: by mail-pg1-x542.google.com with SMTP id r64-v6so3779941pgr.0 for ; Sat, 18 Aug 2018 12:01:31 -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 :mime-version:content-transfer-encoding; bh=9zkXeR2EX5jvS1lDqF0b0jg60XTfD48rcxo8+2EITsk=; b=Yvriur9gCwY5yTkj39WnjdWI0HhIsK8fja3+/gRCT4yDA+fLQ70bpOLyN1Ax2OWax1 FMMIBxMztzGzxK+lCavbDPYiCUUt+BJ2xMYUTNJDOdgVizhHNa1nFUWY/NvFf7+hGXYB tSO1F/JFZ+iBiPov5EmmImluItZCLkHf74HRo= 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:mime-version:content-transfer-encoding; bh=9zkXeR2EX5jvS1lDqF0b0jg60XTfD48rcxo8+2EITsk=; b=e2Mwh184vCOGFWdet2OX74TNqRcH7/GBT0bxEvy3O05tnnlPLebDcXTYZvJYD+XYDG SpBcajuM0saTotEbLGolaMVPY2mY9jIVTHdFZW6bu8Wqx6wbLuyEPGyBW4bRTNsyluCB 5o89SOqOgj7mh8w1jrxJv+4P9pXhH9g/DI5bWQIQ+ivozZwHuZ8jkz6ersKBLwc3g0qO u1tEeC6iTbhABiidO0uGqjlYR0A292aF3aTPpUNSYl0Y5Lfs9EHxibfebknl+GSMuwVo dCSSmv5VWduPK4mIZQz7gBm62OWGzWKtp0O3don0NyhNAHXUjne8YPYJqA/Cz4+J6QmL 8hdw== X-Gm-Message-State: AOUpUlFKvDewWYDUynNHCJhrcwDJ7tyidoNXBV4FBNzPuewg4UzciyGM YwsBp6IMPB1f9P747VatWgffquAl4SY= X-Received: by 2002:a63:7c43:: with SMTP id l3-v6mr6311746pgn.311.1534618890671; Sat, 18 Aug 2018 12:01:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id q85-v6sm9362783pfa.151.2018.08.18.12.01.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Aug 2018 12:01:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 18 Aug 2018 12:01:09 -0700 Message-Id: <20180818190118.12911-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180818190118.12911-1-richard.henderson@linaro.org> References: <20180818190118.12911-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v4 07/16] 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" Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 60 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) -- 2.17.1 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; }