From 228bb9aee22326333e5dfa3e3f522f87f85e84e9 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sat, 20 Aug 2022 12:03:50 +0300 Subject: lpass: try to change the dir a second time if the dir exists Let's unite two conditions. So, if mkdir() returns a non-zero value and errno equals EEXIST, we'll give a change and do chdir() again. --- src/lpass.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/lpass.c') diff --git a/src/lpass.c b/src/lpass.c index 2fcc1ad..70b4b80 100644 --- a/src/lpass.c +++ b/src/lpass.c @@ -69,12 +69,11 @@ static int goto_maindir() if(errno == ENOENT) { // create main directory: result = mkdir(rootdir, S_IRWXU); - if(result) { - if(errno != EEXIST) - print_error("Error: %s\n", strerror(errno)); - } - else // try again: + if(result && errno != EEXIST) { + print_error("Error: %s\n", strerror(errno)); + } else { // try again: retval = chdir(rootdir); + } } else { print_error("Error: %s\n", strerror(errno)); } -- cgit v1.2.3-18-g5258