diff options
author | Joursoir <chat@joursoir.net> | 2022-08-23 20:07:00 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-08-24 16:12:48 +0300 |
commit | e770b00c6d5ec3ab15928e95450edc2ab47023f1 (patch) | |
tree | 0656ac8bb9976c63dec829f31dc762ee4799251a | |
parent | fc73a96f8d6ee8ec2deb6414a8cb54bd588fc590 (diff) | |
download | lock-password-e770b00c6d5ec3ab15928e95450edc2ab47023f1.tar.gz lock-password-e770b00c6d5ec3ab15928e95450edc2ab47023f1.tar.bz2 lock-password-e770b00c6d5ec3ab15928e95450edc2ab47023f1.zip |
cmd_generate: replace errprint_*() with print_error()
This is one of the steps on the way to get rid of errprint_*() macros
and handle errors by yourself. For more context see other patches
under the same topic specified below.
TOPIC=drop_errprint
-rw-r--r-- | src/exec-cmd.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 014012e..7145fc4 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -298,12 +298,16 @@ int cmd_generate(int argc, char *argv[]) return 1; } - if(pass_length < minlen_pass || pass_length > maxlen_pass) - errprint_r(1, "You typed an incorrect length\n"); + if(pass_length < minlen_pass || pass_length > maxlen_pass) { + print_error("Error: You typed an incorrect length\n"); + return 1; + } result = check_sneaky_paths(path); - if(result) - errprint_r(1, "You have used forbidden paths\n"); + if(result) { + print_error("Error: You have used forbidden paths\n"); + return 1; + } result = file_exist(path); if(result == F_ISFILE) { @@ -312,16 +316,19 @@ int cmd_generate(int argc, char *argv[]) return 1; } } - else if(result == F_ISDIR) - errprint_r(1, "You can't generate password for directory\n"); + else if(result == F_ISDIR) { + print_error("Error: You can't generate password for directory\n"); + return 1; + } // generate password char *g_pass = gen_password(pass_length); result = insert_pass(path, g_pass); if(result) { + print_error("Error: Can't add password to LockPassword\n"); free(g_pass); - errprint_r(1, "Can't add password to LockPassword\n"); + return 1; } if(flag_copy) |