[hackers] [lsw] Improve compliance with our coding style || Tom Schwindl

From: <git_AT_suckless.org>
Date: Sun, 3 Jul 2022 17:12:37 +0200 (CEST)

commit 10096682a8901258b65d759fa175d052cd4f302d
Author: Tom Schwindl <schwindl_AT_posteo.de>
AuthorDate: Sun Jul 3 14:22:31 2022 +0000
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
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
_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);
 }
 
Received on Sun Jul 03 2022 - 17:12:37 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 03 2022 - 17:24:30 CEST