[PATCH 19/25] XkbFindSrvLedInfo: remove extraneous name-clashing sli variable

Alan Coopersmith alan.coopersmith at oracle.com
Sun Dec 11 10:16:32 PST 2011


Variable is already defined outside the outer if statement, and
there's no need to redefine inside the if statement.

No point in setting sli before if (dev->kbdfeed->xkb_sli==NULL)
check - if check is true, we immediately set it, if check is false,
we immediately return without further reference or use of it.

The one thing we do with it inside the inner if statement is store
an allocation in it for a brief moment before writing to the final
destination, which is immediately returned to the caller.

In short, there's no benefit to the variable at all in this block,
it just gives the optimizer more code to figure out how to omit.

Fixes gcc warning:
xkbLEDs.c: In function 'XkbFindSrvLedInfo':
xkbLEDs.c:683:19: warning: declaration of 'sli' shadows a previous local
xkbLEDs.c:679:18: warning: shadowed declaration is here

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 xkb/xkbLEDs.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index 515e9b7..24fcd3b 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -680,11 +680,9 @@ XkbSrvLedInfoPtr	sli;
 
     /* optimization to check for most common case */
     if (((class==XkbDfltXIClass)&&(id==XkbDfltXIId))&&(dev->kbdfeed)) {
-	XkbSrvLedInfoPtr	sli;
-	sli= dev->kbdfeed->xkb_sli;
 	if (dev->kbdfeed->xkb_sli==NULL) {
-	    sli= XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,needed_parts);
-	    dev->kbdfeed->xkb_sli= sli;
+	    dev->kbdfeed->xkb_sli=
+		XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,needed_parts);
 	}
 	return dev->kbdfeed->xkb_sli;
     }
-- 
1.7.3.2



More information about the xorg-devel mailing list