From: tb Date: Wed, 27 Mar 2024 06:47:52 +0000 (+0000) Subject: Unify up_ref implementations in libssl X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c89933381575bd468fbf76d8d795bf1630976236;p=openbsd Unify up_ref implementations in libssl ok jsing --- diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index bb9779bbe99..76a906f13a5 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.321 2024/03/02 11:48:55 tb Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.322 2024/03/27 06:47:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -605,8 +605,7 @@ LSSL_ALIAS(SSL_free); int SSL_up_ref(SSL *s) { - int refs = CRYPTO_add(&s->references, 1, CRYPTO_LOCK_SSL); - return (refs > 1) ? 1 : 0; + return CRYPTO_add(&s->references, 1, CRYPTO_LOCK_SSL) > 1; } LSSL_ALIAS(SSL_up_ref); @@ -2217,8 +2216,7 @@ LSSL_ALIAS(SSL_CTX_free); int SSL_CTX_up_ref(SSL_CTX *ctx) { - int refs = CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); - return ((refs > 1) ? 1 : 0); + return CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX) > 1; } LSSL_ALIAS(SSL_CTX_up_ref); diff --git a/lib/libssl/ssl_sess.c b/lib/libssl/ssl_sess.c index 355193c470c..cb985cadb56 100644 --- a/lib/libssl/ssl_sess.c +++ b/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.124 2024/01/24 14:05:10 jsing Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.125 2024/03/27 06:47:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -897,8 +897,7 @@ LSSL_ALIAS(SSL_SESSION_free); int SSL_SESSION_up_ref(SSL_SESSION *ss) { - int refs = CRYPTO_add(&ss->references, 1, CRYPTO_LOCK_SSL_SESSION); - return (refs > 1) ? 1 : 0; + return CRYPTO_add(&ss->references, 1, CRYPTO_LOCK_SSL_SESSION) > 1; } LSSL_ALIAS(SSL_SESSION_up_ref);