slirp: Fix spurious error report when sending directly
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 31 May 2018 19:24:19 +0000 (21:24 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Fri, 1 Jun 2018 14:45:49 +0000 (16:45 +0200)
Move check to where it actually is useful, and reduce scope of 'len'
variable along the way.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
slirp/socket.c

index e2a71c9b04dd2b79fe5a33114abf3aeef570cf50..08fe98907d08b3b49b5aff08140c6b84142a6dfd 100644 (file)
@@ -340,7 +340,7 @@ sosendoob(struct socket *so)
        struct sbuf *sb = &so->so_rcv;
        char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
 
-       int n, len;
+       int n;
 
        DEBUG_CALL("sosendoob");
        DEBUG_ARG("so = %p", so);
@@ -359,7 +359,7 @@ sosendoob(struct socket *so)
                 * send it all
                 */
                uint32_t urgc = so->so_urgc;
-               len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
+               int len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
                if (len > urgc) {
                        len = urgc;
                }
@@ -374,13 +374,13 @@ sosendoob(struct socket *so)
                        len += n;
                }
                n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
-       }
-
 #ifdef DEBUG
-       if (n != len) {
-               DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
-       }
+               if (n != len) {
+                       DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
+               }
 #endif
+       }
+
        if (n < 0) {
                return n;
        }