[hackers] [sbase] crypt: error status code if an error occured in a file series || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 23 Mar 2014 13:27:28 +0100

commit 18b6e4016108182834d08f54c15daad3a459da9f
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Mar 23 12:30:34 2014 +0100

    crypt: error status code if an error occured in a file series
    
    Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>

diff --git a/util/crypt.c b/util/crypt.c
index 5787def..1c797a4 100644
--- a/util/crypt.c
+++ b/util/crypt.c
_AT_@ -10,6 +10,7 @@ cryptmain(int argc, char *argv[],
           struct crypt_ops *ops, uint8_t *md, size_t sz)
 {
         FILE *fp;
+ int ret = EXIT_SUCCESS;
 
         if (argc == 0) {
                 cryptsum(ops, stdin, "<stdin>", md);
_AT_@ -18,15 +19,18 @@ cryptmain(int argc, char *argv[],
                 for (; argc > 0; argc--) {
                         if((fp = fopen(*argv, "r")) == NULL) {
                                 weprintf("fopen %s:", *argv);
+ ret = EXIT_FAILURE;
                                 continue;
                         }
- cryptsum(ops, fp, *argv, md);
- mdprint(md, *argv, sz);
+ if(cryptsum(ops, fp, *argv, md) == 1)
+ ret = EXIT_FAILURE;
+ else
+ mdprint(md, *argv, sz);
                         fclose(fp);
                         argv++;
                 }
         }
- return EXIT_SUCCESS;
+ return ret;
 }
 
 int
_AT_@ -40,7 +44,7 @@ cryptsum(struct crypt_ops *ops, FILE *fp, const char *f,
         while ((n = fread(buf, 1, sizeof(buf), fp)) > 0)
                 ops->update(ops->s, buf, n);
         if (ferror(fp)) {
- eprintf("read error: %s:", f);
+ weprintf("read error: %s:", f);
                 return 1;
         }
         ops->sum(ops->s, md);
Received on Sun Mar 23 2014 - 13:27:28 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 23 2014 - 13:36:19 CET