ubusd: fix issue caused by an implicit cast
[project/ubus.git] / ubusd.c
diff --git a/ubusd.c b/ubusd.c
index 7279a70..5409b7f 100644 (file)
--- a/ubusd.c
+++ b/ubusd.c
@@ -148,12 +148,13 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free)
 
        if (!cl->tx_queue[cl->txq_cur]) {
                written = ubus_msg_writev(cl->sock.fd, ub, 0);
-               if (written >= ub->len + sizeof(ub->hdr))
-                       goto out;
 
                if (written < 0)
                        written = 0;
 
+               if (written >= ub->len + sizeof(ub->hdr))
+                       goto out;
+
                cl->txq_ofs = written;
 
                /* get an event once we can write to the socket again */