summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2026-02-15 22:59:13 +0000
committerHiltjo Posthuma <hiltjo@codemadness.org>2026-02-20 15:31:28 +0100
commit5c9f30300bec2f7eec9ba61d0c11df999e17f860 (patch)
tree820a06457800ff5ae5d20ff8ffe8124dc3e931ff /dwm.c
parentfix not updating _NET_ACTIVE_WINDOW (diff)
downloaddwm-5c9f30300bec2f7eec9ba61d0c11df999e17f860.tar.gz
dwm-5c9f30300bec2f7eec9ba61d0c11df999e17f860.zip
getstate: fix access type and remove redundant cast
WM_STATE is defined to be format == 32 which xlib returns as `long` and so accessing it as `unsigned char` is incorrect. and also &p is already an `unsigned char **` and so the cast was completely redundant. given the redundant cast, i assume `p` was `long *` at some time but was changed to `unsigned char *` later, but the pointer access (and the cast) wasn't updated. also add a `format == 32` check as safety measure before accessing, just in case.
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index fc4232e..a5e1ce9 100644
--- a/dwm.c
+++ b/dwm.c
@@ -897,10 +897,10 @@ getstate(Window w)
897 Atom real; 897 Atom real;
898 898
899 if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], 899 if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
900 &real, &format, &n, &extra, (unsigned char **)&p) != Success) 900 &real, &format, &n, &extra, &p) != Success)
901 return -1; 901 return -1;
902 if (n != 0) 902 if (n != 0 && format == 32)
903 result = *p; 903 result = *(long *)p;
904 XFree(p); 904 XFree(p);
905 return result; 905 return result;
906} 906}