1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-29 09:52:29 +01:00

util: simplify the code for 'find_terminal_emulator' (Coverity #50076)

As pointed by Coverity, the code was making an explicit use of a null
pointer, which is certainly not what was initially expected. The code was
simplified to fix the case and to make it easier to understand and
maintain.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-16 20:15:16 +02:00
committed by Carlos R. Mafra
parent 382337c980
commit b9eb99ca73

View File

@@ -39,16 +39,12 @@ static char *terminals[] = {
*/
char *find_terminal_emulator(void)
{
char *path, *t, *ret;
char *path, *t;
int i;
path = t = ret = NULL;
t = getenv("WMMENU_TERMINAL");
if (t) {
ret = wstrdup(t);
return ret;
}
if (t)
return wstrdup(t);
path = getenv("PATH");
if (!path)
@@ -56,18 +52,13 @@ char *find_terminal_emulator(void)
for (i = 0; terminals[i]; i++) {
t = wfindfile(path, terminals[i]);
if (t)
break;
if (t) {
wfree(t);
return wstrdup(terminals[i]);
}
}
if (t)
ret = wstrdup(basename(t));
else
ret = wstrdup(t);
wfree(t);
return ret;
return NULL;
}
/* tokenize `what' (LC_MESSAGES or LANG if `what' is NULL) in the form of