From patchwork Wed Nov 18 11:15:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 38740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 32B8B1007D1 for ; Wed, 18 Nov 2009 22:18:08 +1100 (EST) Received: from localhost ([127.0.0.1]:33418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAiY0-000080-Uo for incoming@patchwork.ozlabs.org; Wed, 18 Nov 2009 06:18:04 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAiWM-00082g-6M for qemu-devel@nongnu.org; Wed, 18 Nov 2009 06:16:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAiWH-0007yr-Ks for qemu-devel@nongnu.org; Wed, 18 Nov 2009 06:16:21 -0500 Received: from [199.232.76.173] (port=48376 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAiWH-0007yd-Ac for qemu-devel@nongnu.org; Wed, 18 Nov 2009 06:16:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4601) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NAiWG-0002AO-RB for qemu-devel@nongnu.org; Wed, 18 Nov 2009 06:16:17 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAIBGGBX022810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Nov 2009 06:16:16 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAIBGElk009990; Wed, 18 Nov 2009 06:16:15 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 18 Nov 2009 12:15:10 +0100 Message-Id: <1258542910-724-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH] posix-aio-compat: Fix error check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Checking for nbytes < 0 is pointless as long as it's a size_t. If we want to use negative numbers for error codes, we should use signed types. Signed-off-by: Kevin Wolf Reviewed-by: Christoph Hellwig --- posix-aio-compat.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/posix-aio-compat.c b/posix-aio-compat.c index ac247e1..dc14f53 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -117,7 +117,7 @@ static void thread_create(pthread_t *thread, pthread_attr_t *attr, if (ret) die2(ret, "pthread_create"); } -static size_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) +static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) { int ret; @@ -136,7 +136,7 @@ static size_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) return aiocb->aio_nbytes; } -static size_t handle_aiocb_flush(struct qemu_paiocb *aiocb) +static ssize_t handle_aiocb_flush(struct qemu_paiocb *aiocb) { int ret; @@ -176,7 +176,7 @@ qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) #endif -static size_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb) +static ssize_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb) { size_t offset = 0; ssize_t len; @@ -199,10 +199,10 @@ static size_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb) return len; } -static size_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf) +static ssize_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf) { - size_t offset = 0; - size_t len; + ssize_t offset = 0; + ssize_t len; while (offset < aiocb->aio_nbytes) { if (aiocb->aio_type & QEMU_AIO_WRITE) @@ -230,9 +230,9 @@ static size_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf) return offset; } -static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb) +static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb) { - size_t nbytes; + ssize_t nbytes; char *buf; if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) { @@ -308,7 +308,7 @@ static void *aio_thread(void *unused) while (1) { struct qemu_paiocb *aiocb; - size_t ret = 0; + ssize_t ret = 0; qemu_timeval tv; struct timespec ts;