From 823aa07d5607ba165db3652541583f51e60c605d Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 24 Aug 2022 09:29:00 +0300 Subject: cmd_move: 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 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 905e478..19bacec 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -409,15 +409,21 @@ int cmd_move(int argc, char *argv[]) dbgprint("new-path = %s\n", new_path); result = check_sneaky_paths(old_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(old_path); - if(result == F_NOEXIST) - errprint_r(1, "No such file exists\n"); + if(result == F_NOEXIST) { + print_error("Error: No such file exists\n"); + return 1; + } result = check_sneaky_paths(new_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(new_path); if(result != F_NOEXIST) { if(!flag_force) { @@ -427,8 +433,10 @@ int cmd_move(int argc, char *argv[]) } result = rename(old_path, new_path); - if(result) - errprint_r(1, "%s\n", strerror(errno)); + if(result) { + print_error("Error: %s\n", strerror(errno)); + return 1; + } return 0; } -- cgit v1.2.3-18-g5258