diff options
author | Andy Polyakov <appro@openssl.org> | 2018-08-05 16:50:41 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-08-07 08:56:54 +0200 |
commit | 5b37fef04a2b765835361f0652aaa0c41ed1b842 (patch) | |
tree | 47677e73f897a8b5921437c53c93070e61dec321 /crypto/x509/by_dir.c | |
parent | 28ad73181aeb3b0b027d53d3266159f4b2e15d5b (diff) |
Harmonize use of sk_TYPE_find's return value.
In some cases it's about redundant check for return value, in some
cases it's about replacing check for -1 with comparison to 0.
Otherwise compiler might generate redundant check for <-1. [Even
formatting and readability fixes.]
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6860)
Diffstat (limited to 'crypto/x509/by_dir.c')
-rw-r--r-- | crypto/x509/by_dir.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 9d5a571c59..11ac52ce3c 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -329,10 +329,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, */ CRYPTO_THREAD_write_lock(ctx->lock); j = sk_X509_OBJECT_find(xl->store_ctx->objs, &stmp); - if (j != -1) - tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j); - else - tmp = NULL; + tmp = sk_X509_OBJECT_value(xl->store_ctx->objs, j); CRYPTO_THREAD_unlock(ctx->lock); /* If a CRL, update the last file suffix added for this */ @@ -343,11 +340,10 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type, * Look for entry again in case another thread added an entry * first. */ - if (!hent) { + if (hent == NULL) { htmp.hash = h; idx = sk_BY_DIR_HASH_find(ent->hashes, &htmp); - if (idx >= 0) - hent = sk_BY_DIR_HASH_value(ent->hashes, idx); + hent = sk_BY_DIR_HASH_value(ent->hashes, idx); } if (hent == NULL) { hent = OPENSSL_malloc(sizeof(*hent)); |