]> Sergey Matveev's repositories - nnn.git/commitdiff
Minor refactor
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 4 Feb 2020 17:40:46 +0000 (23:10 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 4 Feb 2020 17:51:50 +0000 (23:21 +0530)
src/nnn.c

index f2b46e8ebaa23ccf3438b7450487c66f22b75ccc..cc70bf9daa86ffb70639138119bf93c62887e573 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -6395,21 +6395,16 @@ static bool setup_config(void)
 
 static bool set_tmp_path(void)
 {
-       char *path;
+        char *tmp = "/tmp";
+        char *path = xdiraccess(tmp) ? tmp : getenv("TMPDIR");
 
-       if (xdiraccess("/tmp"))
-               g_tmpfplen = (uchar)xstrlcpy(g_tmpfpath, "/tmp", TMP_LEN_MAX);
-       else {
-               path = getenv("TMPDIR");
-               if (path)
-                       g_tmpfplen = (uchar)xstrlcpy(g_tmpfpath, path, TMP_LEN_MAX);
-               else {
-                       fprintf(stderr, "set TMPDIR\n");
-                       return FALSE;
-               }
-       }
+        if (!path) {
+                fprintf(stderr, "set TMPDIR\n");
+                return FALSE;
+        }
 
-       return TRUE;
+        g_tmpfplen = (uchar)xstrlcpy(g_tmpfpath, path, TMP_LEN_MAX);
+        return TRUE;
 }
 
 static void cleanup(void)