From: Ian Jackson Subject: Re: [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match Date: Mon, 19 May 2014 12:31:58 +0100 Message-ID: <21369.60334.450961.817480@mariner.uk.xensource.com> References: <1400273296-12438-1-git-send-email-andryuk@aero.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1400273296-12438-1-git-send-email-andryuk@aero.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jason Andryuk Cc: Daniel De Graaf , Stefano Stabellini , Ian Campbell , Rafal Wojtczuk , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"): > 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. This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment. Thanks, Ian. > Signed-off-by: Jason Andryuk > --- > tools/libvchan/io.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c > index 804c63c..6e6e239 100644 > --- a/tools/libvchan/io.c > +++ b/tools/libvchan/io.c > @@ -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; > -- > 1.8.3.1 >