In applyrules(), the return value of XGetClassHint is not checked.
ch is also initialised to {0}, which, I believe, is reduntant if
XGetClassHint is successful.
If XGetClassHint is successful, the structure pointers should also be valid,
therefore a check for NULL would be redundant.
The global static variable dc is initialised to {0}, which is redundant,
being a static.
Here is a patch for the above.
Please tell me if my assumptions are incorrect.
diff -r b08055744a2b -r 80fe655809cd dwm.c
--- a/dwm.c Wed Aug 27 20:55:31 2008 +0100
+++ b/dwm.c Wed Aug 27 23:18:35 2008 +0100
@@ -233,7 +233,7 @@
static Client *stack = NULL;
static Cursor cursor[CurLast];
static Display *dpy;
-static DC dc = {0};
+static DC dc;
static Layout *lt[] = { NULL, NULL };
static Window root, barwin;
/* configuration, allows nested code to access above variables */
@@ -247,10 +247,11 @@
applyrules(Client *c) {
unsigned int i;
Rule *r;
- XClassHint ch = { 0 };
+ XClassHint ch;
/* rule matching */
- XGetClassHint(dpy, c->win, &ch);
+ if (0 == XGetClassHint(dpy, c->win, &ch))
+ return;
for(i = 0; i < LENGTH(rules); i++) {
r = &rules[i];
if((!r->title || strstr(c->name, r->title))
@@ -260,10 +261,8 @@
c->tags |= r->tags & TAGMASK;
}
}
- if(ch.res_class)
- XFree(ch.res_class);
- if(ch.res_name)
- XFree(ch.res_name);
+ XFree(ch.res_class);
+ XFree(ch.res_name);
if(!c->tags)
c->tags = tagset[seltags];
}
-- Cheers, FilippoReceived on Wed Aug 27 2008 - 22:22:44 UTC
This archive was generated by hypermail 2.2.0 : Wed Aug 27 2008 - 22:24:04 UTC