commit 10096682a8901258b65d759fa175d052cd4f302d
Author:     Tom Schwindl <[email protected]>
AuthorDate: Sun Jul 3 14:22:31 2022 +0000
Commit:     Hiltjo Posthuma <[email protected]>
CommitDate: Sun Jul 3 17:11:42 2022 +0200

    Improve compliance with our coding style

diff --git a/lsw.c b/lsw.c
index c7d5171..497d6d2 100644
--- a/lsw.c
+++ b/lsw.c
@@ -8,7 +8,7 @@
 static Atom netwmname;
 static Display *dpy;
 
-char *
+static char *
 getname(Window win)
 {
        static char buf[BUFSIZ];
@@ -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;
@@ -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);
 }
 

Reply via email to