From patchwork Fri Jun 1 07:30:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137462 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp603347lji; Fri, 1 Jun 2018 00:31:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxxRqkJi0Fl2d6NU6kEG5NwXBmlpLPmXJHOiFFsltBJcALWdt318zgBTYPwLkmL959Sd0E X-Received: by 2002:a37:cc10:: with SMTP id r16-v6mr8929014qki.95.1527838298278; Fri, 01 Jun 2018 00:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838298; cv=none; d=google.com; s=arc-20160816; b=TqC9t8s8xAMfR3ja0mQhNxdQM4tXPZyEoBLrONb5XUJeG1Wq37DbEWeUwfTWVL4Z1B VSF1U8+koYyS3EvVJVLABmIRqLXzgJ9WKyCBw5KVJVqnA37YN1Y4MrZ3UICgOahmL2cA txGeMRSNfhnH5obx1HRuJk0OozJ131qyoTYCZmpjD9VIauHt2A1odXNE1UxgmPZfoK+y iYCNouHTWYA8xHbfuSonlYCGnIpCX9Rm43LbCxQFZ3sMjF6zsVOELMaGyEik/7LZYlsj FOvFEe2BlSifFfz1Ux3qtZE0hBtQyp0jBkxWVKpRFAJhuzlCikbHzyGNUfJngJkDytXX xX0w== 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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=eictNcVgz3mQMBVkGOCkC084JkDn1T3kY56dZZn3ipTFIZnCX5kGWI5D6ixVL0mXMp ps3hkKfF0ID3SGyA87waALESsYW2M6lEYjjRoEys1zX7BfSjZIYbmoBTcewve1ac6wKB L5atRGnRODxQxZACjxwKcHrZjWbtJjyKhFuXuWOoJDTNEcjrzTHhnaPsRZy+LzscxYxT duhbWv9levldIjkEJcg0japVcSNhUcuOaLYe4S0Rdi9Fb2GltOz959y5JEMHYfDlBF+s xz0AcFq7KC3ti5tfq4KrXVbkBtPZYL2uht2gJnq2L1T2LmgvtPnAwT3Ml+AdYcn37fpo sxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H1+tD2Mw; 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 c85-v6si10447470qkj.206.2018.06.01.00.31.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:31:38 -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=H1+tD2Mw; 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]:47811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXB-0005TL-M1 for patch@linaro.org; Fri, 01 Jun 2018 03:31:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWc-0005PS-L3 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWZ-0000EP-B0 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:02 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWZ-0000DK-07 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:30:59 -0400 Received: by mail-pl0-x244.google.com with SMTP id i5-v6so14819939plt.2 for ; Fri, 01 Jun 2018 00:30:58 -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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=H1+tD2Mwc87Z0uX0F2Z47UdZd+7x93RN7ZaAnrgU4+0lEnNMm9QGVKjj/VDAl693rt nOpw2HiWH5G2ZSyw+R/zF9PgTJiBq0gxgU0mHYVG1VWBiwk2vtMq+R4H+xVZanJ/Gn/Y 5iaJJrgPRpkzrUeBmezYZ9sRrXXzFtFPsSnbM= 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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=keDonHk4zink9EpDZd+l1u7LOCcpHGvlVhYT9m5KzqCZAyuDIoONYlH+AKr9IJOlAl zqNLV4E+H/92DwKKLlTREHyAhfDpNMENudD1nnvlONtPuI8jXo2se1XvC393nCia4EBN o/M9MV3+YpfQLAA+3eSq20X5DiwuKOvzzUqghDVdo7uSIzOQK2hC2Iq2RQBbVmksjwlu xYyLoB3XSH54rfpJOGsM39nJJB2HVkosNp3NQvPzzpC9NMwwdTmyJYsIOaVqc6mg/09T sg4+JYmiWZorImhbbWaqcebaLCOmU8Mpev34JRDDILwG/mg/OW2OSuk2oCTLvClJrtxy Cgcw== X-Gm-Message-State: ALKqPwcJD//WsPNbP/tIBXYCNWvYXL+/+9DSL7cddGWsqEo3BR+GH6+e YELeh7wIRebqXNSLPnW7ncn6/uYCxK4= X-Received: by 2002:a17:902:6ac6:: with SMTP id i6-v6mr10386294plt.31.1527838257436; Fri, 01 Jun 2018 00:30:57 -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.30.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:20 -0700 Message-Id: <20180601073050.8054-4-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:c01::244 Subject: [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf 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 | 187 +++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 95 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 258aff0411..d0bf650c62 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8025,7 +8025,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return 0; } else { if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; @@ -8039,7 +8039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_write: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; @@ -8070,7 +8070,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_openat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); return ret; @@ -8091,7 +8091,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_open_by_handle_at: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = do_open_by_handle_at(arg1, arg2, arg3); fd_trans_unregister(ret); @@ -8099,7 +8099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_close: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } fd_trans_unregister(arg1); return get_errno(close(arg1)); @@ -8163,7 +8163,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_linkat) case TARGET_NR_linkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void * p2 = NULL; if (!arg2 || !arg4) @@ -8190,7 +8190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_unlinkat) case TARGET_NR_unlinkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8324,7 +8324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mknodat) case TARGET_NR_mknodat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8350,7 +8350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_lseek: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(lseek(arg1, arg2, arg3)); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) @@ -8497,7 +8497,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct timeval *tvp, tv[2]; if (arg3) { @@ -8543,7 +8543,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -8590,7 +8590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_renameat) case TARGET_NR_renameat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg2); @@ -8607,7 +8607,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_renameat2) case TARGET_NR_renameat2: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg2); @@ -8633,7 +8633,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mkdirat) case TARGET_NR_mkdirat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8651,7 +8651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_dup: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(dup(arg1)); if (ret >= 0) { @@ -8752,7 +8752,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(dup2(arg1, arg2)); if (ret >= 0) { @@ -8766,7 +8766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int host_flags; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if ((arg3 & ~TARGET_O_CLOEXEC) != 0) { return -EINVAL; @@ -9370,7 +9370,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (contains_hostfd(&rfds) || contains_hostfd(&wfds) || contains_hostfd(&efds)) { - goto ebadf; + return -TARGET_EBADF; } /* @@ -9455,7 +9455,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_symlinkat) case TARGET_NR_symlinkat: if (is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg1); @@ -9511,7 +9511,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_readlinkat) case TARGET_NR_readlinkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; fn = lock_user_string(arg2); @@ -9582,7 +9582,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, v6 = tswapal(v[5]); unlock_user(v, arg1, 0); if (is_hostfd(v5)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), @@ -9590,7 +9590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #else if (is_hostfd(arg5)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), @@ -9605,7 +9605,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #define MMAP_SHIFT 12 #endif if (is_hostfd(arg5)) { - goto ebadf; + return -TARGET_EBADF; } ret = target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), @@ -9660,18 +9660,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_ftruncate: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(ftruncate(arg1, arg2)); case TARGET_NR_fchmod: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchmod(arg1, arg2)); #if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -9736,7 +9736,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fstatfs: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; @@ -9771,7 +9771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fstatfs64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; @@ -9787,117 +9787,117 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_accept case TARGET_NR_accept: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_accept4(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_accept4 case TARGET_NR_accept4: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_accept4(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_bind(arg1, arg2, arg3); #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_connect(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getpeername(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getsockname(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getsockopt(arg1, arg2, arg3, arg4, arg5); #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(listen(arg1, arg2)); #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmsg(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_send case TARGET_NR_send: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendto(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmsg(arg1, arg2, arg3, 1); #endif #ifdef TARGET_NR_sendmmsg case TARGET_NR_sendmmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); case TARGET_NR_recvmmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(shutdown(arg1, arg2)); #endif @@ -9922,7 +9922,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); #endif @@ -10031,7 +10031,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_fstat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { ret = get_errno(fstat(arg1, &st)); #if defined(TARGET_NR_stat) || defined(TARGET_NR_lstat) @@ -10191,7 +10191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_fsync: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fsync(arg1)); case TARGET_NR_clone: @@ -10304,7 +10304,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchdir(arg1)); #ifdef TARGET_NR_bdflush /* not on x86_64 */ @@ -10324,7 +10324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { int64_t res; #if !defined(__NR_llseek) @@ -10346,7 +10346,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_getdents case TARGET_NR_getdents: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #ifdef EMULATE_GETDENTS_WITH_GETDENTS #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 @@ -10481,7 +10481,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct linux_dirent64 *dirp; abi_long count = arg3; @@ -10633,12 +10633,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* NOTE: the flock constant seems to be the same for every Linux platform */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(safe_flock(arg1, arg2)); case TARGET_NR_readv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); if (vec != NULL) { @@ -10651,7 +10651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_writev: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -10665,7 +10665,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_preadv) case TARGET_NR_preadv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); if (vec != NULL) { @@ -10683,7 +10683,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_pwritev) case TARGET_NR_pwritev: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -10703,7 +10703,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fdatasync(arg1)); #endif @@ -10955,7 +10955,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (regpairs_aligned(cpu_env, num)) { arg4 = arg5; @@ -10968,7 +10968,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_pwrite64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (regpairs_aligned(cpu_env, num)) { arg4 = arg5; @@ -11067,7 +11067,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, off_t off; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if (arg3) { ret = get_user_sal(off, arg3); @@ -11092,7 +11092,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, off_t off; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if (arg3) { ret = get_user_s64(off, arg3); @@ -11161,7 +11161,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); #endif @@ -11196,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstat(arg1, &st)); if (!is_error(ret)) @@ -11211,7 +11211,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_newfstatat: #endif if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -11299,7 +11299,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fchownat) case TARGET_NR_fchownat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -11628,7 +11628,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchown(arg1, arg2, arg3)); #endif @@ -11725,7 +11725,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * pairs of 32-bit registers. */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = posix_fadvise(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2); @@ -11737,7 +11737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if defined(TARGET_PPC) || defined(TARGET_XTENSA) /* 6 args: fd, advice, offset (high, low), len (high, low) */ @@ -11766,7 +11766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } /* 5 args: fd, offset (high, low), len, advice */ if (regpairs_aligned(cpu_env, num)) { @@ -11789,7 +11789,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_fadvise64: #endif if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #ifdef TARGET_S390X switch (arg4) { @@ -11815,7 +11815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } { int cmd; @@ -11958,7 +11958,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fsetxattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n, *v = 0; if (arg3) { @@ -12005,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fgetxattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n, *v = 0; if (arg3) { @@ -12045,7 +12045,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fremovexattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n; n = lock_user_string(arg2); @@ -12190,7 +12190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_utimensat) case TARGET_NR_utimensat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct timespec *tsp, ts[2]; if (!arg3) { @@ -12239,7 +12239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -12252,7 +12252,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(sys_inotify_rm_watch(arg1, arg2)); #endif @@ -12353,7 +12353,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_tee case TARGET_NR_tee: if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } else { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } @@ -12362,7 +12362,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_splice case TARGET_NR_splice: if (is_hostfd(arg1) || is_hostfd(arg3)) { - goto ebadf; + return -TARGET_EBADF; } else { loff_t loff_in, loff_out; loff_t *ploff_in = NULL, *ploff_out = NULL; @@ -12395,7 +12395,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -12438,7 +12438,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), @@ -12452,7 +12452,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 #if defined(TARGET_MIPS) @@ -12471,7 +12471,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_sync_file_range2: /* This is like sync_file_range but the arguments are reordered */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), @@ -12485,14 +12485,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_signalfd4) case TARGET_NR_signalfd4: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_signalfd4(arg1, arg2, arg4); #endif #if defined(TARGET_NR_signalfd) case TARGET_NR_signalfd: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_signalfd4(arg1, arg2, 0); #endif @@ -12512,7 +12512,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct epoll_event *epp = 0; if (is_hostfd(arg1) || is_hostfd(arg3)) { - goto ebadf; + return -TARGET_EBADF; } if (arg4) { struct target_epoll_event *target_ep; @@ -12547,7 +12547,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int timeout = arg4; if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { return -TARGET_EINVAL; @@ -12819,7 +12819,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_gettime: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct itimerspec its_curr; @@ -12835,7 +12835,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_settime: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct itimerspec its_new, its_old, *p_new; @@ -12870,7 +12870,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) case TARGET_NR_setns: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(setns(arg1, arg2)); #endif @@ -12896,9 +12896,6 @@ fail: efault: ret = -TARGET_EFAULT; goto fail; -ebadf: - ret = -TARGET_EBADF; - goto fail; } abi_long do_syscall(void *cpu_env, int num, abi_long arg1,