aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-01 22:26:52 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-01 22:26:52 +0530
commita54a23eae53f024b1ae5fbebaa4567d167ca8884 (patch)
tree2e9a994af97f0e53062dd42696a1f7c1456916ab
parent146f24e5de94759349d0b1cdc54daca6514da79d (diff)
downloadnnn-a54a23eae53f024b1ae5fbebaa4567d167ca8884.tar.gz
Minor refactor
-rw-r--r--src/nnn.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 1443e67..5663bf6 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -849,10 +849,10 @@ static void xdelay(useconds_t delay)
static char confirm_force(bool selection)
{
- char str[64];
+ char str[32];
int r;
- snprintf(str, 64, messages[MSG_FORCE_RM],
+ snprintf(str, 32, messages[MSG_FORCE_RM],
(selection ? xitoa(nselected) : "current"), (selection ? "(s)" : ""));
r = get_input(str);
@@ -1589,7 +1589,7 @@ static int join(pid_t p, uchar flag)
static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag)
{
pid_t pid;
- int status, retstatus = 0xFFFF;
+ int status = 0, retstatus = 0xFFFF;
char *argv[EXEC_ARGS_MAX] = {0};
char *cmd = NULL;
@@ -1618,14 +1618,11 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
DPRINTF_S("NULL or too many args");
return retstatus;
}
+ } else
+ argv[status++] = file;
- argv[status++] = arg1;
- argv[status] = arg2;
- } else {
- argv[0] = file;
- argv[1] = arg1;
- argv[2] = arg2;
- }
+ argv[status] = arg1;
+ argv[++status] = arg2;
if (flag & F_NORMAL)
exitcurses();
@@ -6483,7 +6480,7 @@ static bool setup_config(void)
if (!xdg)
len = strlen(home) + 1 + 21; /* add length of "/.config/nnn/sessions" */
- cfgdir = (char *)malloc(len);
+ cfgdir = (char *)malloc(len - 9); /* Subtract length of sessions */
plugindir = (char *)malloc(len);
sessiondir = (char *)malloc(len);
if (!cfgdir || !plugindir || !sessiondir) {