[RFC,06/11] stdio_pclose: return -errno on error
diff mbox

Message ID 1320175230-27980-7-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Nov. 1, 2011, 7:20 p.m. UTC
This is what qemu_fclose() expects.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 savevm.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

Eduardo Habkost Nov. 2, 2011, 12:32 p.m. UTC | #1
On Tue, Nov 01, 2011 at 05:20:25PM -0200, Eduardo Habkost wrote:
> This is what qemu_fclose() expects.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  savevm.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/savevm.c b/savevm.c
> index 3c746a6..63dd719 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -233,8 +233,9 @@ static int stdio_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
>  static int stdio_pclose(void *opaque)
>  {
>      QEMUFileStdio *s = opaque;
> -    int ret;
> -    ret = pclose(s->stdio_file);
> +    int ret = 0;
> +    if (pclose(s->stdio_file) == -1)
> +        ret = -errno;
>      g_free(s);
>      return ret;

Self-NACK. We have to return the pclose() return value here, because
exec_close() needs it.

Thanks to Paolo for spotting it.

Patch
diff mbox

diff --git a/savevm.c b/savevm.c
index 3c746a6..63dd719 100644
--- a/savevm.c
+++ b/savevm.c
@@ -233,8 +233,9 @@  static int stdio_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
 static int stdio_pclose(void *opaque)
 {
     QEMUFileStdio *s = opaque;
-    int ret;
-    ret = pclose(s->stdio_file);
+    int ret = 0;
+    if (pclose(s->stdio_file) == -1)
+        ret = -errno;
     g_free(s);
     return ret;
 }