aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-22 09:00:00 +0300
committerJoursoir <chat@joursoir.net>2022-08-22 16:20:14 +0300
commit70a5a003747c26412b2d89afe180de6fc8e8d423 (patch)
tree9fd1eaa086e17c87df1890f4a8af4c1d3bf4debc
parent0689d7efa8b6e9f1377e7e62b7755dc4370a01c3 (diff)
downloadlock-password-70a5a003747c26412b2d89afe180de6fc8e8d423.tar.gz
lock-password-70a5a003747c26412b2d89afe180de6fc8e8d423.tar.bz2
lock-password-70a5a003747c26412b2d89afe180de6fc8e8d423.zip
cmd_init: 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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/exec-cmd.c b/src/exec-cmd.c
index 63db087..621acd1 100644
--- a/src/exec-cmd.c
+++ b/src/exec-cmd.c
@@ -48,14 +48,18 @@ int cmd_init(int argc, char *argv[])
// create .gpg-key in storage
FILE *filekey = fopen(GPGKEY_FILE, "w");
- if(!filekey)
- errprint_r(1, "%s\n", strerror(errno));
+ if(!filekey) {
+ print_error("Error: %s\n", strerror(errno));
+ return 1;
+ }
result = fputs(gpg_key, filekey);
- if(result == EOF)
- errprint_ptr(&retval, 1, "%s\n", strerror(errno));
- else
+ if(result == EOF) {
+ print_error("Error: %s\n", strerror(errno));
+ retval = 1;
+ } else {
printf("LockPassword initialized for %s\n", gpg_key);
+ }
fclose(filekey);
return retval;