applied anonymous patch, I don't think the reversed array access has semantic side-effects
authorAnselm R Garbe <anselm@garbe.us>
Fri, 07 Jan 2011 16:05:22 +0000
changeset 1530 072c62ed10f2
parent 1529 23b71491e149
child 1531 606ac98e35df
child 1539 e2a9bd720b6e
applied anonymous patch, I don't think the reversed array access has semantic side-effects
dwm.c
--- a/dwm.c	Thu Dec 02 10:16:47 2010 +0000
+++ b/dwm.c	Fri Jan 07 16:05:22 2011 +0000
@@ -980,7 +980,7 @@
 void
 initfont(const char *fontstr) {
 	char *def, **missing;
-	int i, n;
+	int n;
 
 	missing = NULL;
 	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
@@ -996,7 +996,7 @@
 		dc.font.ascent = dc.font.descent = 0;
 		XExtentsOfFontSet(dc.font.set);
 		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
-		for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
+		while(n--) {
 			dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
 			dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
 			xfonts++;
@@ -1014,14 +1014,13 @@
 
 Bool
 isprotodel(Client *c) {
-	int i, n;
+	int n;
 	Atom *protocols;
 	Bool ret = False;
 
 	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
-		for(i = 0; !ret && i < n; i++)
-			if(protocols[i] == wmatom[WMDelete])
-				ret = True;
+		while(!ret && n--)
+			ret = protocols[n] == wmatom[WMDelete];
 		XFree(protocols);
 	}
 	return ret;
@@ -1029,12 +1028,10 @@
 
 #ifdef XINERAMA
 static Bool
-isuniquegeom(XineramaScreenInfo *unique, size_t len, XineramaScreenInfo *info) {
-	unsigned int i;
-
-	for(i = 0; i < len; i++)
-		if(unique[i].x_org == info->x_org && unique[i].y_org == info->y_org
-		&& unique[i].width == info->width && unique[i].height == info->height)
+isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) {
+	while(n--)
+		if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org
+		&& unique[n].width == info->width && unique[n].height == info->height)
 			return False;
 	return True;
 }