[PATCH 2/2] xkb: don't assign garbage value to led_return.

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 6 22:57:01 PST 2009


As the comment for the function states, led_return is undefined if map is
NULL. We might as well skip writing to it then.

Found by clang.

Reported-by: Tomas Carnecky <tom at dbservice.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 xkb/xkb.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 00ae29c..57bf5de 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -3273,20 +3273,22 @@ _XkbFindNamedIndicatorMap(XkbSrvLedInfoPtr sli, Atom indicator,
                           int *led_return)
 {
     XkbIndicatorMapPtr  map;
-    int                 led;
 
     /* search for the right indicator */
     map = NULL;
     if (sli->names && sli->maps) {
+	int led;
+
 	for (led = 0; (led < XkbNumIndicators) && (map == NULL); led++) {
 	    if (sli->names[led] == indicator) {
 		map= &sli->maps[led];
 		break;
 	    }
 	}
+
+	*led_return = led;
     }
 
-    *led_return = led;
     return map;
 }
 
-- 
1.6.5.2



More information about the xorg-devel mailing list