From 26d676725d062bde8778a36b567221a39e28bdd7 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Fri, 19 Aug 2022 22:20:27 +0300 Subject: lpass: use new macro to output error(s) 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/lpass.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lpass.c b/src/lpass.c index dd28dcf..f2281e2 100644 --- a/src/lpass.c +++ b/src/lpass.c @@ -26,6 +26,7 @@ #include "constants.h" #include "exec-cmd.h" #include "xstd.h" +#include "output.h" struct cmd_struct { const char *cmd; @@ -68,7 +69,7 @@ static int goto_maindir() result = mkdir(rootdir, S_IRWXU); if(result) { if(errno != EEXIST) - errprint_ptr(&retval, 1, "%s", strerror(errno)); + print_error("Error: %s\n", strerror(errno)); } else // try again: retval = chdir(rootdir); @@ -80,11 +81,13 @@ static int goto_maindir() int main(int argc, char *argv[]) { - if(!isatty(STDIN_FILENO)) - errprint_r(1, "Please, use a terminal to run this application\n"); + if(!isatty(STDIN_FILENO)) { + print_error("Please, use a terminal to run this application\n"); + return 1; + } if(goto_maindir()) - errprint_r(1, "%s", strerror(errno)); + return 1; struct cmd_struct *ptr = get_cmd(argv[1]); if(ptr) -- cgit v1.2.3-18-g5258