Patchwork [3/5] linux-user: move write to own function

login
register
mail settings
Submitter riku.voipio@linaro.org
Date Oct. 12, 2012, 6:24 p.m.
Message ID <a07823cf2cc1b1f71e1324db7cf3ec45639c7432.1350063473.git.riku.voipio@linaro.org>
Download mbox | patch
Permalink /patch/191177/
State New
Headers show

Comments

riku.voipio@linaro.org - Oct. 12, 2012, 6:24 p.m.
From: Riku Voipio <riku.voipio@linaro.org>

In preparations for for refactoring the main switch/case out

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Patch

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)))