From 70a5a003747c26412b2d89afe180de6fc8e8d423 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Mon, 22 Aug 2022 09:00:00 +0300 Subject: 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 --- src/exec-cmd.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-18-g5258