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_vpm.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_vpm.c')
-rw-r--r-- | crypto/x509/x509_vpm.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c index 16d27f91b5..aea186295c 100644 --- a/crypto/x509/x509_vpm.c +++ b/crypto/x509/x509_vpm.c @@ -555,10 +555,9 @@ int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) return 0; } else { idx = sk_X509_VERIFY_PARAM_find(param_table, param); - if (idx != -1) { - ptmp = sk_X509_VERIFY_PARAM_value(param_table, idx); + if (idx >= 0) { + ptmp = sk_X509_VERIFY_PARAM_delete(param_table, idx); X509_VERIFY_PARAM_free(ptmp); - (void)sk_X509_VERIFY_PARAM_delete(param_table, idx); } } if (!sk_X509_VERIFY_PARAM_push(param_table, param)) @@ -588,9 +587,9 @@ const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name) X509_VERIFY_PARAM pm; pm.name = (char *)name; - if (param_table) { + if (param_table != NULL) { idx = sk_X509_VERIFY_PARAM_find(param_table, &pm); - if (idx != -1) + if (idx >= 0) return sk_X509_VERIFY_PARAM_value(param_table, idx); } return OBJ_bsearch_table(&pm, default_table, OSSL_NELEM(default_table)); |