aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-23 20:14:00 +0300
committerJoursoir <chat@joursoir.net>2022-08-24 16:13:17 +0300
commitfef54a8338cdd4a07717543f8954ad79d312efc0 (patch)
tree6a8fe2be71f5b960034999d3b9d77d5ec9f3ae4a
parente770b00c6d5ec3ab15928e95450edc2ab47023f1 (diff)
downloadlock-password-fef54a8338cdd4a07717543f8954ad79d312efc0.tar.gz
lock-password-fef54a8338cdd4a07717543f8954ad79d312efc0.tar.bz2
lock-password-fef54a8338cdd4a07717543f8954ad79d312efc0.zip
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
-rw-r--r--src/exec-cmd.c24
1 files 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;
}