From patchwork Tue Jan 8 22:59:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 210559 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 45D4F2C00AE for ; Wed, 9 Jan 2013 10:05:30 +1100 (EST) Received: from localhost ([::1]:51413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsiEa-0006Hn-A7 for incoming@patchwork.ozlabs.org; Tue, 08 Jan 2013 18:05:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsiEG-0006BM-NY for qemu-devel@nongnu.org; Tue, 08 Jan 2013 18:05:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsiEF-0006bB-FT for qemu-devel@nongnu.org; Tue, 08 Jan 2013 18:05:08 -0500 Received: from mail-ia0-f175.google.com ([209.85.210.175]:37645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsiEF-0006al-BT for qemu-devel@nongnu.org; Tue, 08 Jan 2013 18:05:07 -0500 Received: by mail-ia0-f175.google.com with SMTP id 21so768650iay.34 for ; Tue, 08 Jan 2013 15:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=1lO9GnUUhN1TXw6TSYaPJpf7HpmBmgESVu02itXhj6Q=; b=OQadp1TyuBqk3J10esefQgPaVfdR1lLTRuZ5kAIzcbQSG/5W5ad5EDKVGbVNeHNtoz hUdmCCvtSJ3hgfq26Q2U6gKZ6dplj9b7MIMnCFvvOzGAUsz/Xp0J3DPD62q+IQR3veQw A52EONMU0ZIXaRvIthmHzywJTDe7it42WJplu0yYJqDslt1nmHLQX2tnp8gKAu/ZZWWZ H14aarF6NMFDStud0phscTI2eiPa/iDeHeOcKfpMpiUjWAFg//kgavr2izMDhU4tDifF Wu69waVTChxPnKEuF0ggAxM15f/uNlKmZcgaeFslstgcbplAlJm/qKCWGdwoKYOSwncc DSOQ== X-Received: by 10.43.117.197 with SMTP id fn5mr50285468icc.7.1357686306781; Tue, 08 Jan 2013 15:05:06 -0800 (PST) Received: from localhost ([32.97.110.59]) by mx.google.com with ESMTPS id i9sm686739igl.9.2013.01.08.15.05.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Jan 2013 15:05:05 -0800 (PST) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 8 Jan 2013 16:59:58 -0600 Message-Id: <1357686009-13139-2-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357686009-13139-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1357686009-13139-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.175 Cc: aliguori@us.ibm.com, tomoki.sekiyama.qu@hitachi.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 01/12] qemu-ga: guest_file_handle_find(): take an Error argument 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: Luiz Capitulino Signed-off-by: Luiz Capitulino Reviewed-by: Michael Roth *Fixed missing space character in error message Signed-off-by: Michael Roth --- qga/commands-posix.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index a657201..bbef66d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -111,7 +111,7 @@ static void guest_file_handle_add(FILE *fh) QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next); } -static GuestFileHandle *guest_file_handle_find(int64_t id) +static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err) { GuestFileHandle *gfh; @@ -122,6 +122,7 @@ static GuestFileHandle *guest_file_handle_find(int64_t id) } } + error_setg(err, "handle '%" PRId64 "' has not been found", id); return NULL; } @@ -160,12 +161,11 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E void qmp_guest_file_close(int64_t handle, Error **err) { - GuestFileHandle *gfh = guest_file_handle_find(handle); + GuestFileHandle *gfh = guest_file_handle_find(handle, err); int ret; slog("guest-file-close called, handle: %ld", handle); if (!gfh) { - error_set(err, QERR_FD_NOT_FOUND, "handle"); return; } @@ -182,14 +182,13 @@ void qmp_guest_file_close(int64_t handle, Error **err) struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, int64_t count, Error **err) { - GuestFileHandle *gfh = guest_file_handle_find(handle); + GuestFileHandle *gfh = guest_file_handle_find(handle, err); GuestFileRead *read_data = NULL; guchar *buf; FILE *fh; size_t read_count; if (!gfh) { - error_set(err, QERR_FD_NOT_FOUND, "handle"); return NULL; } @@ -228,11 +227,10 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, guchar *buf; gsize buf_len; int write_count; - GuestFileHandle *gfh = guest_file_handle_find(handle); + GuestFileHandle *gfh = guest_file_handle_find(handle, err); FILE *fh; if (!gfh) { - error_set(err, QERR_FD_NOT_FOUND, "handle"); return NULL; } @@ -265,13 +263,12 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset, int64_t whence, Error **err) { - GuestFileHandle *gfh = guest_file_handle_find(handle); + GuestFileHandle *gfh = guest_file_handle_find(handle, err); GuestFileSeek *seek_data = NULL; FILE *fh; int ret; if (!gfh) { - error_set(err, QERR_FD_NOT_FOUND, "handle"); return NULL; } @@ -291,12 +288,11 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset, void qmp_guest_file_flush(int64_t handle, Error **err) { - GuestFileHandle *gfh = guest_file_handle_find(handle); + GuestFileHandle *gfh = guest_file_handle_find(handle, err); FILE *fh; int ret; if (!gfh) { - error_set(err, QERR_FD_NOT_FOUND, "handle"); return; }