From e770b00c6d5ec3ab15928e95450edc2ab47023f1 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 23 Aug 2022 20:07:00 +0300 Subject: 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 --- src/exec-cmd.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/exec-cmd.c') 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) -- cgit v1.2.3-18-g5258