return errors from iterations

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15747 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-07-25 21:50:28 +00:00
parent 7b05df1363
commit 810020a64d

View File

@@ -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); ret = hx509_certs_next_cert(certs, cursor, &c);
if (ret) if (ret)
break; break;
if (c == NULL) if (c == NULL) {
ret = 0;
break; break;
}
ret = (*fn)(ctx, c); ret = (*fn)(ctx, c);
hx509_cert_free(c); hx509_cert_free(c);
if (ret) 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); hx509_certs_end_seq(certs, cursor);
return 0; return ret;
} }
int int
@@ -221,7 +223,7 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r)
{ {
hx509_cursor cursor; hx509_cursor cursor;
hx509_cert c; hx509_cert c;
int ret, found = 0; int ret;
*r = NULL; *r = NULL;
@@ -232,14 +234,14 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r)
if (ret) if (ret)
return ret; return ret;
c = NULL;
while (1) { while (1) {
ret = hx509_certs_next_cert(certs, cursor, &c); ret = hx509_certs_next_cert(certs, cursor, &c);
if (ret) if (ret)
break; break;
if (c == NULL) if (c == NULL)
break; break;
found = _hx509_query_match_cert(q, c); if (_hx509_query_match_cert(q, c)) {
if (found) {
*r = c; *r = c;
break; break;
} }
@@ -247,8 +249,9 @@ _hx509_certs_find(hx509_certs certs, const hx509_query *q, hx509_cert *r)
} }
hx509_certs_end_seq(certs, cursor); hx509_certs_end_seq(certs, cursor);
if (ret)
if (!found) return ret;
if (c == NULL)
return ENOENT; return ENOENT;
return 0; return 0;