diff options
author | Joursoir <chat@joursoir.net> | 2022-08-20 12:03:50 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-08-22 00:07:35 +0300 |
commit | 228bb9aee22326333e5dfa3e3f522f87f85e84e9 (patch) | |
tree | 82b41c878d1a35d2aa50298687ab4a308a76075e /src | |
parent | 56d9586130f0a5157543f24f567444608819c19c (diff) | |
download | lock-password-228bb9aee22326333e5dfa3e3f522f87f85e84e9.tar.gz lock-password-228bb9aee22326333e5dfa3e3f522f87f85e84e9.tar.bz2 lock-password-228bb9aee22326333e5dfa3e3f522f87f85e84e9.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/lpass.c | 9 |
1 files changed, 4 insertions, 5 deletions
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)); } |