fix return value
This commit is contained in:
parent
8ff4fd7c25
commit
0d8f847bb9
25
xcwd.c
25
xcwd.c
@ -61,15 +61,15 @@ static Window focusedWindow()
|
|||||||
{
|
{
|
||||||
Atom type;
|
Atom type;
|
||||||
Window focuswin, root, *children;
|
Window focuswin, root, *children;
|
||||||
int format, status, focusrevert;
|
int format, status;
|
||||||
unsigned long nitems, after;
|
unsigned long nitems, after;
|
||||||
unsigned char *data;
|
|
||||||
unsigned int nchildren;
|
unsigned int nchildren;
|
||||||
|
unsigned char *data;
|
||||||
|
|
||||||
dpy = XOpenDisplay (NULL);
|
dpy = XOpenDisplay (NULL);
|
||||||
if (!dpy)
|
if (!dpy)
|
||||||
exit (1);
|
exit(EXIT_FAILURE);
|
||||||
XGetInputFocus (dpy, &focuswin, &focusrevert);
|
XGetInputFocus (dpy, &focuswin, (int[1]){});
|
||||||
root = XDefaultRootWindow(dpy);
|
root = XDefaultRootWindow(dpy);
|
||||||
if(root == focuswin)
|
if(root == focuswin)
|
||||||
return None;
|
return None;
|
||||||
@ -291,17 +291,17 @@ int main(int argc, const char *argv[])
|
|||||||
|
|
||||||
processes_t p;
|
processes_t p;
|
||||||
long pid;
|
long pid;
|
||||||
|
int ret = EXIT_SUCCESS;
|
||||||
Window w = focusedWindow();
|
Window w = focusedWindow();
|
||||||
if (w == None)
|
if (w == None)
|
||||||
return getHomeDirectory();
|
return getHomeDirectory();
|
||||||
|
|
||||||
pid = windowPid(w);
|
pid = windowPid(w);
|
||||||
p = getProcesses();
|
p = getProcesses();
|
||||||
if(p == NULL)
|
if(!p)
|
||||||
return getHomeDirectory();
|
return getHomeDirectory();
|
||||||
if (pid != -1) {
|
if(pid != -1)
|
||||||
qsort(p->ps, p->n, sizeof(struct proc_s), ppidCmp);
|
qsort(p->ps, p->n, sizeof(struct proc_s), ppidCmp);
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
long unsigned int size;
|
long unsigned int size;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -322,15 +322,12 @@ int main(int argc, const char *argv[])
|
|||||||
pid = res->pid;
|
pid = res->pid;
|
||||||
LOG("Found %s (%ld)\n", res->name, res->pid);
|
LOG("Found %s (%ld)\n", res->name, res->pid);
|
||||||
}
|
}
|
||||||
if (size != 0)
|
if (size)
|
||||||
free(strings);
|
free(strings);
|
||||||
}
|
}
|
||||||
if (pid == -1 || !cwdOfDeepestChild(p, pid)) {
|
if (pid == -1 || !cwdOfDeepestChild(p, pid))
|
||||||
LOG("%s", "getenv $HOME...\n");
|
ret = getHomeDirectory();
|
||||||
fprintf(stdout, "%s\n", getenv("HOME"));
|
|
||||||
}
|
|
||||||
freeProcesses(p);
|
freeProcesses(p);
|
||||||
|
return ret;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user