From 9cd560ffc854f5c4f8c45e0620cb7d6f84f80c98 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 12 Mar 2025 04:58:04 +0000 Subject: Streamline X509_VERIFY_PARAM_add0_table() Unindent, use correct type for idx (int rather than size_t) and make this mess a bit more pleasant on the eyes. ok jsing --- src/lib/libcrypto/x509/x509_vpm.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/x509/x509_vpm.c b/src/lib/libcrypto/x509/x509_vpm.c index 056b691ddd..4b333e2a2d 100644 --- a/src/lib/libcrypto/x509/x509_vpm.c +++ b/src/lib/libcrypto/x509/x509_vpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vpm.c,v 1.46 2025/03/12 04:56:26 tb Exp $ */ +/* $OpenBSD: x509_vpm.c,v 1.47 2025/03/12 04:58:04 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -667,25 +667,20 @@ int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) { X509_VERIFY_PARAM *ptmp; - if (!param_table) { + int idx; + + if (param_table == NULL) param_table = sk_X509_VERIFY_PARAM_new(param_cmp); - if (!param_table) - return 0; - } else { - size_t idx; + if (param_table == NULL) + return 0; - if ((idx = sk_X509_VERIFY_PARAM_find(param_table, param)) - != -1) { - ptmp = sk_X509_VERIFY_PARAM_value(param_table, - idx); - X509_VERIFY_PARAM_free(ptmp); - (void)sk_X509_VERIFY_PARAM_delete(param_table, - idx); - } + if ((idx = sk_X509_VERIFY_PARAM_find(param_table, param)) != -1) { + ptmp = sk_X509_VERIFY_PARAM_value(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)) - return 0; - return 1; + + return sk_X509_VERIFY_PARAM_push(param_table, param) > 0; } LCRYPTO_ALIAS(X509_VERIFY_PARAM_add0_table); -- cgit v1.2.3-55-g6feb