From patchwork Wed Aug 22 01:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 144793 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp173938ljw; Tue, 21 Aug 2018 18:20:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzEhyKajH0O7jnY5qWYp5qnKcE0tz+iUfgoysyIVx7XXj2I0HsCxLe4cJwK49perWR1p2fZ X-Received: by 2002:ac8:544c:: with SMTP id d12-v6mr17367383qtq.150.1534900831140; Tue, 21 Aug 2018 18:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534900831; cv=none; d=google.com; s=arc-20160816; b=C4Q9rOTgYr1gBIrwG6BoeF/Sm5Z4pJSeTevsSKP1zQSvLmOcc2uWnE16yOoUtgW1Xb 062riLfO2T9Plxi6ysxZ2d9gKjgsDPZg1J8q5OQSp1cDGilr90JLwzfSmvFbO5Y7ZSjB OfL/Ivu2GLTrm78OazT8RavAUMX+Ea2KeXWwYjEPPh11PZK4z2+rvlTg8gWFvzRWKi/N Ju6E/D8c7WUqIaxsYVftSLKhqOE7DQ+xul18SYBAHy/+Hxs/Sc/2hmA9XRmHOlMsV952 m6QaDwPD3hlw4l56cRGHQBVM24QFEDlMy80kc0YZik1Qr49f/ezCZnkeieuN6XBDdvVb ubvw== 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:arc-authentication-results; bh=xAS48gYbgtfCBqe7MyIBH1aTTTcVy1gSyibLnLGpCdY=; b=1CPxFX0NdO7yeGBdgGq8wh1iu/UDnOihXPX+V41cK8kdtZg9zqeG0V+OEg69rvJaQz dNisbBJAWoKDuRdkYb0l9s1AKlR/ePVCTc+J7ziwHxejE05ZtxMKSLWDIvIFAbz4IJqb +KazV2Yd6ya9OzHdtutGUR+Z3MBCVrhs7FCIzH2TrlgZw0F5TpnSLHrTz/JyYzT8xnBA yVCVuEDVp/HFetpKRrTLZB1GQAFKVMqP1+QxPfeAUYhwVyLGt1jZt5NPmecHexGS8lUZ xaWYxX0HJMSDt4uAkgmUI5aJgRkms7QfLWvXegcr/bEpRvtInFD6Qs7Jma2KjJSjoZ5x YSRQ== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c28-v6si333196qtg.189.2018.08.21.18.20.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 21 Aug 2018 18:20:31 -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; 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" Received: from localhost ([::1]:56436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsHp0-0001TW-JM for patch@linaro.org; Tue, 21 Aug 2018 21:20:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsHk3-00073T-V7 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 21:15:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsHjv-0001uv-4g for qemu-devel@nongnu.org; Tue, 21 Aug 2018 21:15:20 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:56341) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsHjs-0001sb-Tg for qemu-devel@nongnu.org; Tue, 21 Aug 2018 21:15:14 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LqDBo-1gMvZx17tg-00drZB; Wed, 22 Aug 2018 03:14:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 22 Aug 2018 03:14:17 +0200 Message-Id: <20180822011417.11608-8-laurent@vivier.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822011417.11608-1-laurent@vivier.eu> References: <20180822011417.11608-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:0qS5GIr9Fi8mI0LMkv+piT5sWGwD9bDmFzfvM15krOPIbCAvOKb nh8HEtxYH31lXXK34Uj/riaXWR/fEKAZUvUzvAUwh7xqjm/0thxrjLGrjcf1R8wRFn2Wsii bKGciMMX2cZdpkonVP1kYacyxdecClu3ezQCwoRJoWIpz+En/aPb/PPfKEepfBEBqfkLxN1 sopLz+lDEQHjk/rjEvV6A== X-UI-Out-Filterresults: notjunk:1; V01:K0:krBQuI7pvD8=:TvowydZ/Hu19oSwoZd1bnP TYtFybcTuRO2ZWeYQy2ebf8pYbGXg9aJ8rxXSs+UCmXoty4TWvAeU2bkuPDLyENhzWjY5Fh6V QDAfnvYIjzYluw8ZCO1cCbCfaDSZIGrXz53Q9EV/Ee222Ic1BYIHH3P/LuMm3jwKCty11Ntyk ZLgUaDdU2yxETSZSWov0PYpfmSglWGfcMFHCQbjuQpm/bicUz04QC4CQ6TUeTmwprJTVR0LoD ZSNXHQf1FpViiEx3H8QiF1EaA3ipgS1+L8gGunS9qf+5i/RXj+kxAmd/tlYsfPbk5W2BytTby MjoDlvdHqeJdqW6O7Dklp3ERtSYuMAmC2ZMJ2SFvNcGNF1QbplwOmql/cYlDDdNKLxbiHNR8n pwgxBYrR+I4y+8kWBBUEQum9DIi28WqlnYZbSWJ+fzTPwtm3Hcnaydic+FSF55tqxJ6zPiHJt nh3b0QgqUxR0Lmgh8In6Caxbt3sXcyymKa4G/AzWa0htNdQTCoP0g0D18aqdPfrU9nNBm/RIs 0lEIUfBQrs4m5eSEGosExJZ2Vs+QN8MdaJZrBJlMia/nSmMYzbq007aq2SWgujYGBMG9X6T4N PSa/vcGLsg1IQ+JBNqY0vBmxjHWoo5xUlTVcm0slBtVrPXtgANIrh7zMy7Kee22aOWFwihsw4 89s0zJXkUf25NduBMdSt5UAX0DYe82zXKxGuIWykK/J6U1njN4fDuJ+6VE+aXoG9n5tJ0dQx1 FpoR4NvH8NiBDorP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PULL 7/7] 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: Riku Voipio , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Message-Id: <20180818190118.12911-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- 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 57044cf546..02fba7606d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9016,8 +9016,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); @@ -9044,8 +9043,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; @@ -9088,8 +9086,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; @@ -9379,15 +9376,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; } /* @@ -9420,8 +9417,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); @@ -9860,17 +9856,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); @@ -10215,8 +10209,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)); @@ -10616,7 +10609,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; @@ -11072,8 +11065,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])); @@ -11331,8 +11323,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); @@ -11380,8 +11371,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]); @@ -11401,8 +11391,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]); @@ -11477,20 +11466,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; @@ -11956,8 +11942,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); @@ -12599,7 +12584,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; }