From 091ecbe6f0572935d94752ae28823ad2a3eadd39 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 17 Apr 2024 12:19:33 +0530 Subject: c: improve error reporting --- src/libnpass/libnpass.c | 2 +- src/npass/npass.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c index fd6e447..62cbc5e 100644 --- a/src/libnpass/libnpass.c +++ b/src/libnpass/libnpass.c @@ -163,7 +163,7 @@ static int openstore(const char *spath, DIR **dirp) store_type = pass_store_type(spath); if (store_type != PASS_STORE_DIR) - return_err(-EINVAL, "%s Not a passwordstore path", spath); + return (store_type < 0) ? store_type : -EINVAL; if (spath) { r = snprintf(abs_path, sizeof(abs_path), "%s/%s", pass_dir, diff --git a/src/npass/npass.c b/src/npass/npass.c index f78df9d..8fa7113 100644 --- a/src/npass/npass.c +++ b/src/npass/npass.c @@ -8,9 +8,9 @@ #include "util.h" #define return_invalid_usage(err) \ - return_err(err, "%s", "Invalid usage, try $pass help") + return_err(err, "%s", "Invalid usage, try `pass help`") -#define DEF_DEPTTH 16; +#define DEF_DEPTTH 16 #define BLUE "\e[0;34m" #define NCOL "\e[0m" @@ -227,6 +227,9 @@ int main(int argc, char *argv[]) if (!--argc) { r = ls(NULL, 0); } else if (!strcmp("help", *argv)) { + if (argc != 1) + return_invalid_usage(EXIT_FAILURE); + print_usage(); } else if (!strcmp("init", *argv)) { if (argc != 2) -- cgit v1.2.3