From f76fb047c15914ba44dc9423d235484758bcd721 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 25 Nov 2015 13:39:50 +0100 Subject: tools/gpgtar: Improve error handling. * tools/gpgtar-create.c (gpgtar_create): Return an error code, fix error handling. * tools/gpgtar-extract.c (gpgtar_extract): Likewise. * tools/gpgtar-list.c (read_header): Return an error code. (gpgtar_list): Return an error code, fix error handling. (gpgtar_read_header): Return an error code. * tools/gpgtar.c: Add missing include. (main): Print an generic error message if a command failed and no error has been printed yet. * tools/gpgtar.h (gpgtar_{create,extract,list,read_header}): Fix the prototypes accordingly. Signed-off-by: Justus Winter --- tools/gpgtar.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tools/gpgtar.c') diff --git a/tools/gpgtar.c b/tools/gpgtar.c index a86aafef2..714b216d2 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -38,6 +38,7 @@ #include "util.h" #include "i18n.h" #include "sysutils.h" +#include "../common/asshelp.h" #include "../common/openpgpdefs.h" #include "../common/init.h" @@ -158,6 +159,7 @@ ASSUAN_SYSTEM_NPTH_IMPL; int main (int argc, char **argv) { + gpg_error_t err; ARGPARSE_ARGS pargs; const char *fname; int no_more_options = 0; @@ -262,7 +264,9 @@ main (int argc, char **argv) log_info ("note: ignoring option --set-filename\n"); if (files_from) log_info ("note: ignoring option --files-from\n"); - gpgtar_list (fname, !skip_crypto); + err = gpgtar_list (fname, !skip_crypto); + if (err && log_get_errorcount (0) == 0) + log_error ("listing archive failed: %s\n", gpg_strerror (err)); break; case aEncrypt: @@ -271,7 +275,9 @@ main (int argc, char **argv) usage (1); if (opt.filename) log_info ("note: ignoring option --set-filename\n"); - gpgtar_create (null_names? NULL :argv, !skip_crypto); + err = gpgtar_create (null_names? NULL :argv, !skip_crypto); + if (err && log_get_errorcount (0) == 0) + log_error ("creating archive failed: %s\n", gpg_strerror (err)); break; case aDecrypt: @@ -282,7 +288,9 @@ main (int argc, char **argv) if (files_from) log_info ("note: ignoring option --files-from\n"); fname = argc ? *argv : NULL; - gpgtar_extract (fname, !skip_crypto); + err = gpgtar_extract (fname, !skip_crypto); + if (err && log_get_errorcount (0) == 0) + log_error ("extracting archive failed: %s\n", gpg_strerror (err)); break; default: -- cgit v1.2.3