On Sun, Jul 03, 2016 at 06:55:40PM +0200, Markus Teich wrote:
> you should shift the declarations above the updatenumlockmask() call acording 
> to
> "Do not mix declarations and code" from http://suckless.org/coding_style. The
> same for the second removed pair of braces.

An updated patch is attached.

Eric
>From 9b9e01d11ac134b15f24cb59d125d106be7bbdf2 Mon Sep 17 00:00:00 2001
From: Eric Pruitt <eric.pru...@gmail.com>
Date: Sun, 3 Jul 2016 10:10:30 -0700
Subject: [PATCH] Removed unnecessary scope blocks

---
 dwm.c | 60 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/dwm.c b/dwm.c
index b2bc9bd..9901737 100644
--- a/dwm.c
+++ b/dwm.c
@@ -943,41 +943,45 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
 void
 grabbuttons(Client *c, int focused)
 {
+	unsigned int i, j;
+	unsigned int modifiers[4];
 	updatenumlockmask();
-	{
-		unsigned int i, j;
-		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
-		XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
-		if (focused) {
-			for (i = 0; i < LENGTH(buttons); i++)
-				if (buttons[i].click == ClkClientWin)
-					for (j = 0; j < LENGTH(modifiers); j++)
-						XGrabButton(dpy, buttons[i].button,
-						            buttons[i].mask | modifiers[j],
-						            c->win, False, BUTTONMASK,
-						            GrabModeAsync, GrabModeSync, None, None);
-		} else
-			XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
-			            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
-	}
+	modifiers[0] = 0;
+	modifiers[1] = LockMask;
+	modifiers[2] = numlockmask;
+	modifiers[3] = numlockmask|LockMask;
+	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+	if (focused) {
+		for (i = 0; i < LENGTH(buttons); i++)
+			if (buttons[i].click == ClkClientWin)
+				for (j = 0; j < LENGTH(modifiers); j++)
+					XGrabButton(dpy, buttons[i].button,
+								buttons[i].mask | modifiers[j],
+								c->win, False, BUTTONMASK,
+								GrabModeAsync, GrabModeSync, None, None);
+	} else
+		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
+					BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
 }
 
 void
 grabkeys(void)
 {
-	updatenumlockmask();
-	{
-		unsigned int i, j;
-		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
-		KeyCode code;
+	unsigned int i, j;
+	unsigned int modifiers[4];
+	KeyCode code;
 
-		XUngrabKey(dpy, AnyKey, AnyModifier, root);
-		for (i = 0; i < LENGTH(keys); i++)
-			if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
-				for (j = 0; j < LENGTH(modifiers); j++)
-					XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
-						 True, GrabModeAsync, GrabModeAsync);
-	}
+	updatenumlockmask();
+	modifiers[0] = 0;
+	modifiers[1] = LockMask;
+	modifiers[2] = numlockmask;
+	modifiers[3] = numlockmask|LockMask;
+	XUngrabKey(dpy, AnyKey, AnyModifier, root);
+	for (i = 0; i < LENGTH(keys); i++)
+		if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
+			for (j = 0; j < LENGTH(modifiers); j++)
+				XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
+					 True, GrabModeAsync, GrabModeAsync);
 }
 
 void
-- 
2.1.4

Reply via email to