aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-19 22:20:27 +0300
committerJoursoir <chat@joursoir.net>2022-08-21 23:26:04 +0300
commit26d676725d062bde8778a36b567221a39e28bdd7 (patch)
tree2ee745a43b972903b88b7a6baa0b0cb54615d0f4
parentcb97e447c91d6d6c4d24247ac656e27556a28f2a (diff)
downloadlock-password-26d676725d062bde8778a36b567221a39e28bdd7.tar.gz
lock-password-26d676725d062bde8778a36b567221a39e28bdd7.tar.bz2
lock-password-26d676725d062bde8778a36b567221a39e28bdd7.zip
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
-rw-r--r--src/lpass.c11
1 files 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)