On Wed, Dec 9, 2009 at 5:09 PM, Peter Hutterer <[email protected]> wrote: > As the comment for the function states, led_return is undefined if map is > NULL. We might as well skip writing to it then.
If you want to write to led_return only when the returned map is non-null, then you need to move the assignment before the break statement. The value of led is just as much garbage if the loop runs to completion as it was when it hadn't been written to yet; just more predictably so. With that changed I'd give it a Reviewed-by: Jamey Sharp <[email protected]> because, well, why not? > Found by clang. > > Reported-by: Tomas Carnecky <[email protected]> > Signed-off-by: Peter Hutterer <[email protected]> > --- > 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 > > _______________________________________________ > xorg-devel mailing list > [email protected] > http://lists.x.org/mailman/listinfo/xorg-devel > _______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
