From fef54a8338cdd4a07717543f8954ad79d312efc0 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 23 Aug 2022 20:14:00 +0300 Subject: cmd_remove: 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 7145fc4..905e478 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -351,20 +351,28 @@ int cmd_remove(int argc, char *argv[]) } 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_NOEXIST) - errprint_r(1, "No such file exists\n"); + if(result == F_NOEXIST) { + print_error("Error: No such file exists\n"); + return 1; + } if(result == F_ISDIR) { - if(count_dir_entries(path) != 0) - errprint_r(1, "Directory not empty\n"); + if(count_dir_entries(path) != 0) { + print_error("Error: Directory not empty\n"); + return 1; + } } result = remove(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