From: Eduardo Habkost Date: Thu, 10 Nov 2011 12:41:48 +0000 (-0200) Subject: unix_close(): check for close() errors too (v2) X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8160bfbc4d5d0abf78afa557f2d5832dc11cd690;p=qmiga%2Fqemu.git unix_close(): check for close() errors too (v2) In case close() fails, we want to report the error back. Changes v1 -> v2: - Use braces on if statement to match coding style Signed-off-by: Eduardo Habkost Signed-off-by: Anthony Liguori --- diff --git a/migration-unix.c b/migration-unix.c index 8596353d7d..dfcf2033c6 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -40,12 +40,15 @@ static int unix_write(MigrationState *s, const void * buf, size_t size) static int unix_close(MigrationState *s) { + int r = 0; DPRINTF("unix_close\n"); if (s->fd != -1) { - close(s->fd); + if (close(s->fd) < 0) { + r = -errno; + } s->fd = -1; } - return 0; + return r; } static void unix_wait_for_connect(void *opaque)