From e1d599f4c981c214317bf828894c3e0e997f80de Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sun, 9 Jun 2013 20:11:39 +1000 Subject: [PATCH] Fix queue_num_free_elements Return 0 for an unallocated queue, and return the actual number of events (rather than one too little). Signed-off-by: Peter Hutterer --- libevdev/libevdev-int.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index 43cfe8a..5d3502a 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -208,7 +208,10 @@ queue_size(struct libevdev *dev) static inline size_t queue_num_free_elements(struct libevdev *dev) { - return dev->queue_size - dev->queue_next - 1; + if (dev->queue_size == 0) + return 0; + + return dev->queue_size - dev->queue_next; } static inline struct input_event * -- 2.7.4