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/x509_trs.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/x509_trs.c')
-rw-r--r-- | crypto/x509/x509_trs.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c index a9bb88d1e1..d2b0a8af63 100644 --- a/crypto/x509/x509_trs.c +++ b/crypto/x509/x509_trs.c @@ -98,13 +98,14 @@ int X509_TRUST_get_by_id(int id) { X509_TRUST tmp; int idx; + if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX)) return id - X509_TRUST_MIN; - tmp.trust = id; - if (!trtable) + if (trtable == NULL) return -1; + tmp.trust = id; idx = sk_X509_TRUST_find(trtable, &tmp); - if (idx == -1) + if (idx < 0) return -1; return idx + X509_TRUST_COUNT; } |