From 07bbc5111e36990c2ce719a20467c6a3dd605316 Mon Sep 17 00:00:00 2001
Message-Id: <07bbc5111e36990c2ce719a20467c6a3dd605316.1367947969.git.minovotn@redhat.com>
In-Reply-To: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com>
References: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com>
From: Michal Novotny <minovotn@redhat.com>
Date: Tue, 7 May 2013 18:38:05 +0200
Subject: [PATCH 044/114] Revert "qemu-ga: guest_file_handle_find(): take an
 Error argument"

This reverts commit 67d59e6073bac5a7483eae73ad9d75bb8be16b6b.

Reverting as asked by Laszlo in message <51892739.2030807@redhat.com>
because of the ordering issue (most likely) related to supersed
testing.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qga/commands-posix.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 2254559..db6aa6f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -112,7 +112,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, Error **err)
+static GuestFileHandle *guest_file_handle_find(int64_t id)
 {
     GuestFileHandle *gfh;
 
@@ -123,7 +123,6 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
         }
     }
 
-    error_setg(err, "handle '%" PRId64 "' has not been found", id);
     return NULL;
 }
 
@@ -162,11 +161,12 @@ 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, err);
+    GuestFileHandle *gfh = guest_file_handle_find(handle);
     int ret;
 
     slog("guest-file-close called, handle: %ld", handle);
     if (!gfh) {
+        error_set(err, QERR_FD_NOT_FOUND, "handle");
         return;
     }
 
@@ -183,13 +183,14 @@ 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, err);
+    GuestFileHandle *gfh = guest_file_handle_find(handle);
     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,10 +229,11 @@ 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, err);
+    GuestFileHandle *gfh = guest_file_handle_find(handle);
     FILE *fh;
 
     if (!gfh) {
+        error_set(err, QERR_FD_NOT_FOUND, "handle");
         return NULL;
     }
 
@@ -264,12 +266,13 @@ 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, err);
+    GuestFileHandle *gfh = guest_file_handle_find(handle);
     GuestFileSeek *seek_data = NULL;
     FILE *fh;
     int ret;
 
     if (!gfh) {
+        error_set(err, QERR_FD_NOT_FOUND, "handle");
         return NULL;
     }
 
@@ -289,11 +292,12 @@ 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, err);
+    GuestFileHandle *gfh = guest_file_handle_find(handle);
     FILE *fh;
     int ret;
 
     if (!gfh) {
+        error_set(err, QERR_FD_NOT_FOUND, "handle");
         return;
     }
 
-- 
1.7.11.7

