From 810020a64da2a437929b646435d5e13bce241c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 25 Jul 2005 21:50:28 +0000 Subject: [PATCH] return errors from iterations git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15747 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/keyset.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/hx509/keyset.c b/lib/hx509/keyset.c index 62e5d8ab7..00fbb3a61 100644 --- a/lib/hx509/keyset.c +++ b/lib/hx509/keyset.c @@ -177,8 +177,10 @@ hx509_certs_iter(hx509_certs certs, int (*fn)(void *, hx509_cert), void *ctx) ret = hx509_certs_next_cert(certs, cursor, &c); if (ret) break; - if (c == NULL) + if (c == NULL) { + ret = 0; break; + } ret = (*fn)(ctx, c); hx509_cert_free(c); if (ret) @@ -187,7 +189,7 @@ hx509_certs_iter(hx509_certs certs, int (*fn)(void *, hx509_cert), void *ctx) hx509_certs_end_seq(certs, cursor); - return 0; + return ret; } int @@ -221,7 +223,7 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r) { hx509_cursor cursor; hx509_cert c; - int ret, found = 0; + int ret; *r = NULL; @@ -232,14 +234,14 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r) if (ret) return ret; + c = NULL; while (1) { ret = hx509_certs_next_cert(certs, cursor, &c); if (ret) break; if (c == NULL) break; - found = _hx509_query_match_cert(q, c); - if (found) { + if (_hx509_query_match_cert(q, c)) { *r = c; break; } @@ -247,8 +249,9 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r) } hx509_certs_end_seq(certs, cursor); - - if (!found) + if (ret) + return ret; + if (c == NULL) return ENOENT; return 0;