libvchan: Make raw_get_{data_ready, buffer_space} match
authorJason Andryuk <andryuk@aero.org>
Fri, 16 May 2014 20:48:16 +0000 (16:48 -0400)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 2 Jun 2014 13:36:05 +0000 (14:36 +0100)
For writing into a vchan, raw_get_buffer_space used >, allowing the full
ring size to be written.  On the read side, raw_get_data_ready compared
the ring size with >=.  This mismatch means a completely filled buffer
cannot be read.  Fix this by making the size checks identical.

Signed-off-by: Jason Andryuk <andryuk@aero.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libvchan/io.c

index 804c63cca7aabad951a1a0128a42a2028e5ba598..6e6e2395df6c4601d9b16aeea7a33c8cf5d7ac4d 100644 (file)
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
 static inline int raw_get_data_ready(struct libxenvchan *ctrl)
 {
        uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
-       if (ready >= rd_ring_size(ctrl))
+       if (ready > rd_ring_size(ctrl))
                /* We have no way to return errors.  Locking up the ring is
                 * better than the alternatives. */
                return 0;