diff mbox

[09/10] tcp_close(): check for close() errors too

Message ID 1320876205-16113-10-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Nov. 9, 2011, 10:03 p.m. UTC
In case close() fails, we want to report the error back.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 migration-tcp.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Robert Wang Nov. 10, 2011, 8:21 a.m. UTC | #1
2011/11/10 Eduardo Habkost <ehabkost@redhat.com>:
> In case close() fails, we want to report the error back.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  migration-tcp.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/migration-tcp.c b/migration-tcp.c
> index 5aa742c..fd5fd56 100644
> --- a/migration-tcp.c
> +++ b/migration-tcp.c
> @ -40,12 +40,14 @@ static int socket_write(MigrationState *s, const void * buf, size_t size)
>
>  static int tcp_close(MigrationState *s)
>  {
> +    int r = 0;
>     DPRINTF("tcp_close\n");
>     if (s->fd != -1) {
> -        close(s->fd);
> +        if (close(s->fd) < 0)
> +            r = -errno;
Braces {} are necessary, or checkpatch.pl will give warnings, also in
other patches in your series.

No mistake, just reminder. :)
>         s->fd = -1;
>     }
> -    return 0;
> +    return r;
>  }
>
>  static void tcp_wait_for_connect(void *opaque)
> --
> 1.7.3.2
>
>
>
Eduardo Habkost Nov. 10, 2011, 12:36 p.m. UTC | #2
On Thu, Nov 10, 2011 at 04:21:46PM +0800, Dong Xu Wang wrote:
> >     if (s->fd != -1) {
> > -        close(s->fd);
> > +        if (close(s->fd) < 0)
> > +            r = -errno;
> Braces {} are necessary, or checkpatch.pl will give warnings, also in
> other patches in your series.
> 
> No mistake, just reminder. :)

I will send v3 with the coding style fixed (I was supposed to fix this
before submitting v2 but I forgot). Thanks!
diff mbox

Patch

diff --git a/migration-tcp.c b/migration-tcp.c
index 5aa742c..fd5fd56 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -40,12 +40,14 @@  static int socket_write(MigrationState *s, const void * buf, size_t size)
 
 static int tcp_close(MigrationState *s)
 {
+    int r = 0;
     DPRINTF("tcp_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 tcp_wait_for_connect(void *opaque)