<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On 17 November 2014 15:47, Derek Foreman <span dir="ltr"><<a href="mailto:derekf@osg.samsung.com" target="_blank">derekf@osg.samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">While the test is actually correct (for non-negative numbers), it's not<br>
at all clear and seems to be an accidental order of operations mistake.<br>
<br>
Also, add an assert() to make sure this number is never negative.<br>
<br>
Closes bug 86346 - <a href="https://bugs.freedeskto.org/show_bug.cgi?id=86346" target="_blank">https://bugs.freedeskto.org/show_bug.cgi?id=86346</a><br>
<br>
Signed-off-by: Derek Foreman <<a href="mailto:derekf@osg.samsung.com" target="_blank">derekf@osg.samsung.com</a>><br>
---<br>
 src/input.c           | 1 +<br>
 src/libinput-device.c | 2 +-<br>
 2 files changed, 2 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/input.c b/src/input.c<br>
index 5f19875..6784ead 100644<br>
--- a/src/input.c<br>
+++ b/src/input.c<br>
@@ -2209,6 +2209,7 @@ weston_seat_release_keyboard(struct weston_seat *seat)<br>
                weston_keyboard_reset_state(seat->keyboard);<br>
                seat_send_updated_caps(seat);<br>
        }<br>
+       assert(seat->keyboard_device_count >= 0);<br></blockquote><div> </div></span><div>Maybe
 this assert could be right after decrementing of the 
keyboard_device_count? But I don't insist on it. Better here than 
nowhere :)<br></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 }<br>
<br>
 WL_EXPORT void<br>
diff --git a/src/libinput-device.c b/src/libinput-device.c<br>
index 0e3f46d..8a48905 100644<br>
--- a/src/libinput-device.c<br>
+++ b/src/libinput-device.c<br>
@@ -470,7 +470,7 @@ evdev_notify_keyboard_focus(struct weston_seat *seat,<br>
 {<br>
        struct wl_array keys;<br>
<br>
-       if (!seat->keyboard_device_count > 0)<br>
+       if (seat->keyboard_device_count == 0)<br></blockquote><div><br></div></span><div>This
 condition is not equal to the former one (if the former one would be 
written correctly), but is correct IMO. Together with the<br>assert this should work perfectly.<br><br></div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                return;<br>
<br>
        wl_array_init(&keys);<br>
<span><font color="#888888">--<br>
2.1.1<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br></font></span></blockquote><div><br></div></span><div>Reviewed-by: Marek Chalupa <<a href="mailto:mchqwerty@gmail.com" target="_blank">mchqwerty@gmail.com</a>> <br></div></div><br></div></div>
</div></div>