From: Christophe CURIS <christophe.cu...@free.fr>

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.cu...@free.fr>
---
 util/wmmenugen_misc.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/util/wmmenugen_misc.c b/util/wmmenugen_misc.c
index 694ef8b..21c485c 100644
--- a/util/wmmenugen_misc.c
+++ b/util/wmmenugen_misc.c
@@ -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
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to