aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-20 12:03:50 +0300
committerJoursoir <chat@joursoir.net>2022-08-22 00:07:35 +0300
commit228bb9aee22326333e5dfa3e3f522f87f85e84e9 (patch)
tree82b41c878d1a35d2aa50298687ab4a308a76075e
parent56d9586130f0a5157543f24f567444608819c19c (diff)
downloadlock-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.
-rw-r--r--src/lpass.c9
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));
}