From 9607b7c7dd7a368dbdb26322e3609425f63f4a6c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 18 May 2026 22:57:00 +0200 Subject: Keep going in -c mode on error (still exit with value 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common.c b/common.c index 2052553..efaf853 100644 --- a/common.c +++ b/common.c @@ -219,12 +219,12 @@ hash(const char *restrict filename, const struct libkeccak_spec *restrict spec, if (fd < 0) { if (errno == ENOENT) return 1; - eperror(); + goto error; } if ((hex ? generalised_sum_fd_hex : libkeccak_generalised_sum_fd) (fd, &state, spec, suffix, squeezes > 1 ? NULL : hashsum)) - eperror(); + goto error; close(fd); if (squeezes > 2) @@ -234,6 +234,10 @@ hash(const char *restrict filename, const struct libkeccak_spec *restrict spec, libkeccak_state_fast_destroy(&state); return 0; + +error: + fprintf(stderr, "%s: %s: %s\n", argv0, filename, strerror(errno)); + return 2; } @@ -254,10 +258,12 @@ check(const struct libkeccak_spec *restrict spec, long int squeezes, const char int hex, const char *restrict filename, const char *restrict correct_hash) { size_t length = (size_t)((spec->output + 7) / 8); + int ret; - if (access(filename, F_OK) || hash(filename, spec, squeezes, suffix, hex)) { + ret = hash(filename, spec, squeezes, suffix, hex); + if (ret) { printf("%s: Missing\n", filename); - return 1; + return ret; } libkeccak_unhex(hexsum, correct_hash); @@ -399,7 +405,7 @@ check_checksums(const char *restrict filename, const struct libkeccak_spec *rest user_error("file is malformated"); free(buf); - return ret; + return ret > 2 ? 2 : ret; (void) style; } -- cgit v1.2.3-70-g09d2