[systemd-devel] [PATCH 3/5] [uninitialized] No need to check if num is < 0

philippedeswert at gmail.com philippedeswert at gmail.com
Wed Sep 10 02:20:40 PDT 2014


From: Philippe De Swert <philippedeswert at gmail.com>

When num is < 0 we jump to the error handling. However at that time
r is not set yet by keyboard_fill so we most likely get a nonsensical
error. However the num check is not needed as the xkb_state_key_get_syms
will not return negative values. From its documentation:
@returns The number of keysyms in the syms_out array.  If no keysyms
 are produced by the key in the given keyboard state, returns 0 and sets
 syms_out to NULL.

Found with coverity. Fixes: CID#1237784

Signed-off-by: Philippe De Swert <philippedeswert at gmail.com>
---
 src/libsystemd-terminal/idev-keyboard.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index ab9e481..1eafbb1 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -770,9 +770,6 @@ static int keyboard_feed_evdev(idev_keyboard *k, idev_data *data) {
                 /* TODO: update LEDs */
         }
 
-        if (num < 0)
-                goto error;
-
         r = keyboard_fill(k, &k->evdata, data->resync, ev->code, ev->value, num, keysyms);
         if (r < 0)
                 goto error;
-- 
1.8.3.2



More information about the systemd-devel mailing list