aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-24 09:29:00 +0300
committerJoursoir <chat@joursoir.net>2022-08-24 16:16:12 +0300
commit823aa07d5607ba165db3652541583f51e60c605d (patch)
treeac8ccf338ae8f5e39105f73749e8ab4121adf1a8
parentfef54a8338cdd4a07717543f8954ad79d312efc0 (diff)
downloadlock-password-823aa07d5607ba165db3652541583f51e60c605d.tar.gz
lock-password-823aa07d5607ba165db3652541583f51e60c605d.tar.bz2
lock-password-823aa07d5607ba165db3652541583f51e60c605d.zip
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
-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 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;
}