From patchwork Sun Jun 10 03:00:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138077 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2573876lji; Sat, 9 Jun 2018 20:03:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIAJedP+D+2r5kkY3PBXD9ePr6rpSi5xv0+qH/ecrSM8a8mCId5ck0egzbufrf+2oX3Nm87 X-Received: by 2002:ac8:2a96:: with SMTP id b22-v6mr11688792qta.415.1528599796956; Sat, 09 Jun 2018 20:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599796; cv=none; d=google.com; s=arc-20160816; b=TerIDkDc5GT2gdviwXqS5qZEQjPEHHm84DaE1fAIX7JHDHJmTlH6zLXAh7AoZAH/E4 bCshNv4khm4x26yGTaWUqgPUTds1fTrbo5iSdRAIuTc8qrq64eB0sqrjJbic3sWiccyt XRU9m1d2Z3v3UxvVjfXagwpxdlM0QUfNSOmmS+9+ju7t4Ov2kMcFErgEB+0dZcUIekXo p+jOtHV41aspsHHO7x95BgVXpL28wD1cu9l7I/Sh8LpaIiYCJ8j65otnQpGHb22pAZI9 fw/6UJxZTMkv+9GHujf84XFOmrjr1F4xrI007RCLFkTZvgWzPPmj9mCL4NU3caMTjHIt mcIw== 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=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=EJFVeAf8sCttH3/4WT2vWblo7+7ECrxW1nenkLSkwJ83nJcaZE4B3eFBY3ePHm5ZJ6 aunroeGU9+xQguP7eeX61edg17DoswS606qo3ZRgqgZ+O6q0NnW5R168oy8x6zFUx9Tu B1VUCAVx2Wv4tvsxgcnyt80lBPbnvk23z7Qi0CMxhXgq7TmZuUJc/nGYdIxftZMCoRrE V01woLQV3T/2TKihGmavhFZsdS3vJ6n4DjCFtodB5H6CdLH44cAclpWH9dA5/5OSPpPd BMc+R7ntJEOAFHFTk8X3x4kN8d5CiqHQ8opbgbMHrIMTqcXa9/DGWJ4SEXjRexpJVJkk MAjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=boaJHFjO; 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 k72-v6si1011901qkh.83.2018.06.09.20.03.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:03:16 -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=boaJHFjO; 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]:42173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdQ-0001g4-CQ for patch@linaro.org; Sat, 09 Jun 2018 23:03:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcu-0001db-Tj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqct-0003Ag-NB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:44 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:40738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqct-0003AO-EX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:43 -0400 Received: by mail-pg0-x230.google.com with SMTP id l2-v6so8127019pgc.7 for ; Sat, 09 Jun 2018 20:02:43 -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=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=boaJHFjOieYsw1Bkn0eQsrWjzpc0XhWSmRKbONWpSbe9MTQXVnfl5F7+jJNW/PZ/c6 RFNVLiCdtVul+e0US4065gaczx63qfGDQjkkvP/AcvYo7WKnOLoJ8MxvB/Debp5gwEtH ylaay2qwxkCXFhSDBeuzt6FKVmhVsNVgsVg6c= 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=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=G8GfZ/P3LJvMkg3utle/IlZ/d7wBo1nNB/J7JIxcKiHVuVmAi0BuTTOL4vOiZqkjxK ULFMhzZ0sMMqI6TbFTHVUKNlj6fvvPjlSSsgss8nHH2i0tTry5utV4DIDyvH7jWMayoH wHrRNeXI5qvRGkrzealkG0Xs9PKDJ/fmwo5N8/1llQdwmffbfMahbTYK8ICLEGmqqJIA +sgvztBT22i8zmiXkeVXY2A7IDfPECI2trbwpFhhoqjltCgaa4IlV3QnE3+Tly8Hs6UE 6zLCCKScm0YcaZx+BO0pD2rqegkyMzB9Vk/HImpzNHWbdzKH4IgEO1Vwfz8UKwaXs/bS vg6g== X-Gm-Message-State: APt69E3gdaPFvkfoPdMud/wU3etZJ1SagvJj4zPVryy0atTK8g9UcWab 7SOiPxUmgoCsdZK51mLvFly6Gniy51s= X-Received: by 2002:a63:5ec4:: with SMTP id s187-v6mr10207019pgb.72.1528599762153; Sat, 09 Jun 2018 20:02:42 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:39 -1000 Message-Id: <20180610030220.3777-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-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::230 Subject: [Qemu-devel] [PATCH v2 007/108] 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: 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 5a17803732..fd8d48b0da 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8865,8 +8865,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); @@ -8893,8 +8892,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; @@ -8937,8 +8935,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; @@ -9227,15 +9224,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; } /* @@ -9268,8 +9265,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); @@ -9700,17 +9696,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); @@ -10056,8 +10050,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)); @@ -10456,7 +10449,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; @@ -10903,8 +10896,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])); @@ -11162,8 +11154,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); @@ -11211,8 +11202,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]); @@ -11232,8 +11222,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]); @@ -11308,20 +11297,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; @@ -11787,8 +11773,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); @@ -12424,7 +12409,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, gemu_log("qemu: Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; } -fail: return ret; }