From patchwork Fri Oct 12 18:24:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 191177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AAFC52C008A for ; Sat, 13 Oct 2012 05:47:08 +1100 (EST) Received: from localhost ([::1]:49719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjvX-0004SF-Bs for incoming@patchwork.ozlabs.org; Fri, 12 Oct 2012 14:25:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjuk-0002md-4K for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMjue-0006L7-QN for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:49 -0400 Received: from afflict.kos.to ([92.243.29.197]:33086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjue-0006KY-IK for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:44 -0400 Received: by afflict.kos.to (Postfix, from userid 1000) id 6BD0B264C6; Fri, 12 Oct 2012 20:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2012 21:24:40 +0300 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 92.243.29.197 Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 3/5] linux-user: move write to own function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Riku Voipio In preparations for for refactoring the main switch/case out Signed-off-by: Riku Voipio --- linux-user/syscall.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 497cae5..a9bfe8c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5145,6 +5145,16 @@ static abi_long do_read(abi_long arg1, abi_long arg2, abi_long arg3) } return ret; } +static abi_long do_write(abi_long arg1, abi_long arg2, abi_long arg3) +{ + abi_long ret; + void *p; + if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) + return -EFAULT; + ret = write(arg1, p, arg3); + unlock_user(p, arg2, 0); + return ret; +} /* do_syscall() should always have a single exit point at the end so that actions, such as logging of syscall results, can be performed. @@ -5173,10 +5183,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(do_read(arg1, arg2, arg3)); break; case TARGET_NR_write: - if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; - ret = get_errno(write(arg1, p, arg3)); - unlock_user(p, arg2, 0); + ret = get_errno(do_write(arg1, arg2, arg3)); break; case TARGET_NR_open: if (!(p = lock_user_string(arg1)))