From a5b6fcd70f76d41f7f638a5a45a53ffe24bf6d58 Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 16 May 2014 18:35:01 +0000 Subject: [PATCH] save up the failures for the end in the argc == 0. help ok espie --- usr.bin/signify/signify.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c index edd1809c403..4d1a5b291cb 100644 --- a/usr.bin/signify/signify.c +++ b/usr.bin/signify/signify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signify.c,v 1.87 2014/05/16 17:46:07 tedu Exp $ */ +/* $OpenBSD: signify.c,v 1.88 2014/05/16 18:35:01 tedu Exp $ */ /* * Copyright (c) 2013 Ted Unangst * @@ -604,14 +604,13 @@ verifychecksums(char *msg, int argc, char **argv, int quiet) struct ohash_info info = { 0, NULL, ecalloc, efree, NULL }; struct ohash myh; struct checksum c; - char *line, *endline; - const char *e; + char *e, *line, *endline; int hasfailed = 0; int i, rv; unsigned int slot; + ohash_init(&myh, 6, &info); if (argc) { - ohash_init(&myh, 6, &info); for (i = 0; i < argc; i++) { slot = ohash_qlookup(&myh, argv[i]); e = ohash_find(&myh, slot); @@ -639,23 +638,24 @@ verifychecksums(char *msg, int argc, char **argv, int quiet) } } else { if (verifychecksum(&c, quiet) == 0) { - fprintf(stderr, "%s: FAIL\n", c.file); - hasfailed = 1; + slot = ohash_qlookup(&myh, c.file); + e = ohash_find(&myh, slot); + if (e == NULL) { + if (!(e = strdup(c.file))) + err(1, "strdup"); + ohash_insert(&myh, slot, e); + } } } } - if (argc) { - for (i = 0; i < argc; i++) { - slot = ohash_qlookup(&myh, argv[i]); - e = ohash_find(&myh, slot); - if (e != NULL) { - fprintf(stderr, "%s: FAIL\n", argv[i]); - hasfailed = 1; - } - } - ohash_delete(&myh); + for (e = ohash_first(&myh, &slot); e != NULL; e = ohash_next(&myh, &slot)) { + fprintf(stderr, "%s: FAIL\n", e); + hasfailed = 1; + if (argc == 0) + free(e); } + ohash_delete(&myh); if (hasfailed) exit(1); } -- 2.20.1