[hackers] [lsw] [PATCH] Improve compliance with our coding style

From: Tom Schwindl <schwindl_AT_posteo.de>
Date: Sun, 3 Jul 2022 14:22:31 +0000

---
 lsw.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lsw.c b/lsw.c
index c7d5171e7383..497d6d262c1f 100644
--- a/lsw.c
+++ b/lsw.c
_AT_@ -8,7 +8,7 @@
 static Atom netwmname;
 static Display *dpy;
 
-char *
+static char *
 getname(Window win)
 {
 	static char buf[BUFSIZ];
_AT_@ -16,22 +16,23 @@ getname(Window win)
 	int n;
 	XTextProperty prop;
 
-	if (!XGetTextProperty(dpy, win, &prop, netwmname) || prop.nitems == 0)
-		if (!XGetWMName(dpy, win, &prop) || prop.nitems == 0)
+	if (!XGetTextProperty(dpy, win, &prop, netwmname) || !prop.nitems) {
+		if (!XGetWMName(dpy, win, &prop) || !prop.nitems)
 			return "";
+	}
 	if (!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) {
-		strncpy(buf, list[0], sizeof buf);
+		strncpy(buf, list[0], sizeof(buf));
 		XFreeStringList(list);
 	} else {
-		strncpy(buf, (char *)prop.value, sizeof buf);
+		strncpy(buf, (char *)prop.value, sizeof(buf));
 	}
 	XFree(prop.value);
-	buf[sizeof buf - 1] = '\0';
+	buf[sizeof(buf) - 1] = '\0';
 
 	return buf;
 }
 
-void
+static void
 lsw(Window win)
 {
 	unsigned int n;
_AT_@ -40,10 +41,11 @@ lsw(Window win)
 
 	if (!XQueryTree(dpy, win, &dw, &dw, &wins, &n) || !n)
 		return;
-	for (w = &wins[n-1]; w >= &wins[0]; w--)
+	for (w = &wins[n-1]; w >= &wins[0]; w--) {
 		if (XGetWindowAttributes(dpy, *w, &wa)
 		&& !wa.override_redirect && wa.map_state == IsViewable)
 			printf("0x%07lx %s\n", *w, getname(*w));
+	}
 	XFree(wins);
 }
 
-- 
2.37.0
Received on Sun Jul 03 2022 - 16:22:31 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 03 2022 - 16:24:32 CEST