diff options
author | Adrien Schildknecht <adrien+dev@schischi.me> | 2013-08-01 17:47:01 +0200 |
---|---|---|
committer | Adrien Schildknecht <adrien+dev@schischi.me> | 2013-08-01 17:47:01 +0200 |
commit | 0d8f847bb9e0ed5801fb8730c50c813a4220d671 (patch) | |
tree | f13b1ef36e12d9ba5f08c5c1fcedac51e5b570c2 | |
parent | 8ff4fd7c25925cc8a697c5990c8dc81d8302b765 (diff) |
fix return value
-rw-r--r-- | xcwd.c | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -61,15 +61,15 @@ static Window focusedWindow() { Atom type; Window focuswin, root, *children; - int format, status, focusrevert; + int format, status; unsigned long nitems, after; - unsigned char *data; unsigned int nchildren; + unsigned char *data; dpy = XOpenDisplay (NULL); if (!dpy) - exit (1); - XGetInputFocus (dpy, &focuswin, &focusrevert); + exit(EXIT_FAILURE); + XGetInputFocus (dpy, &focuswin, (int[1]){}); root = XDefaultRootWindow(dpy); if(root == focuswin) return None; @@ -291,17 +291,17 @@ int main(int argc, const char *argv[]) processes_t p; long pid; + int ret = EXIT_SUCCESS; Window w = focusedWindow(); if (w == None) return getHomeDirectory(); pid = windowPid(w); p = getProcesses(); - if(p == NULL) + if(!p) return getHomeDirectory(); - if (pid != -1) { + if(pid != -1) qsort(p->ps, p->n, sizeof(struct proc_s), ppidCmp); - } else { long unsigned int size; unsigned int i; @@ -322,15 +322,12 @@ int main(int argc, const char *argv[]) pid = res->pid; LOG("Found %s (%ld)\n", res->name, res->pid); } - if (size != 0) + if (size) free(strings); } - if (pid == -1 || !cwdOfDeepestChild(p, pid)) { - LOG("%s", "getenv $HOME...\n"); - fprintf(stdout, "%s\n", getenv("HOME")); - } + if (pid == -1 || !cwdOfDeepestChild(p, pid)) + ret = getHomeDirectory(); freeProcesses(p); - - return EXIT_SUCCESS; + return ret; } |