Received: from eggs.gnu.org ([2001:4830:134:3::10]:41070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1DJf-0004vD-10 for qemu-devel@nongnu.org; Wed, 17 Dec 2014 07:03:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1DJY-0003ww-Vh for qemu-devel@nongnu.org; Wed, 17 Dec 2014 07:02:54 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:44112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1DJY-0003wk-QM for qemu-devel@nongnu.org; Wed, 17 Dec 2014 07:02:48 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGQ007GW6ZHWT00@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 17 Dec 2014 12:06:53 +0000 (GMT) From: Ilya Palachev Date: Wed, 17 Dec 2014 15:02:42 +0300 Message-id: <1418817762-9727-1-git-send-email-i.palachev@samsung.com> Subject: [Qemu-devel] [PATCH] Force pread64/pwrite64 to return 0 for zero-length buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Vyachelav Barinov , Ilya Palachev According to official standard POSIX.1-2001. pread64 and pwrite64 should return 0 for zero-length buffers as mentioned at http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html Change-Id: Icd66ea29658329fbd5e6461d1def0c78c81d2671 Signed-off-by: Ilya Palachev --- linux-user/syscall.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a41dd43..a08f5ef 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8127,6 +8127,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1, arg4 = arg5; arg5 = arg6; } + if (!arg3) { + ret = 0; + break; + } if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); @@ -8137,6 +8141,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1, arg4 = arg5; arg5 = arg6; } + if (!arg3) { + ret = 0; + break; + } if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); -- 2.1.3