mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-04 04:44:16 +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:
committed by
Carlos R. Mafra
parent
382337c980
commit
b9eb99ca73
@@ -39,16 +39,12 @@ static char *terminals[] = {
|
|||||||
*/
|
*/
|
||||||
char *find_terminal_emulator(void)
|
char *find_terminal_emulator(void)
|
||||||
{
|
{
|
||||||
char *path, *t, *ret;
|
char *path, *t;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
path = t = ret = NULL;
|
|
||||||
|
|
||||||
t = getenv("WMMENU_TERMINAL");
|
t = getenv("WMMENU_TERMINAL");
|
||||||
if (t) {
|
if (t)
|
||||||
ret = wstrdup(t);
|
return wstrdup(t);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = getenv("PATH");
|
path = getenv("PATH");
|
||||||
if (!path)
|
if (!path)
|
||||||
@@ -56,18 +52,13 @@ char *find_terminal_emulator(void)
|
|||||||
|
|
||||||
for (i = 0; terminals[i]; i++) {
|
for (i = 0; terminals[i]; i++) {
|
||||||
t = wfindfile(path, terminals[i]);
|
t = wfindfile(path, terminals[i]);
|
||||||
if (t)
|
if (t) {
|
||||||
break;
|
wfree(t);
|
||||||
|
return wstrdup(terminals[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t)
|
return NULL;
|
||||||
ret = wstrdup(basename(t));
|
|
||||||
else
|
|
||||||
ret = wstrdup(t);
|
|
||||||
|
|
||||||
wfree(t);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tokenize `what' (LC_MESSAGES or LANG if `what' is NULL) in the form of
|
/* tokenize `what' (LC_MESSAGES or LANG if `what' is NULL) in the form of
|
||||||
|
|||||||
Reference in New Issue
Block a user