From: tb Date: Wed, 27 Mar 2024 01:22:30 +0000 (+0000) Subject: Unify *_up_ref() implementations X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d230cbd22815f7ad7a3c2c1208b772d03a671200;p=openbsd Unify *_up_ref() implementations No need for an inconsistently named local variable and a ternary operator. ok jsing --- diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c index 2f490a42f97..ba715392237 100644 --- a/lib/libcrypto/bio/bio_lib.c +++ b/lib/libcrypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.52 2024/03/02 09:22:41 tb Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.53 2024/03/27 01:22:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -198,8 +198,7 @@ LCRYPTO_ALIAS(BIO_vfree); int BIO_up_ref(BIO *bio) { - int refs = CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO); - return (refs > 1) ? 1 : 0; + return CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1; } LCRYPTO_ALIAS(BIO_up_ref); diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c index d8698859f0f..98cc6e77ba1 100644 --- a/lib/libcrypto/dh/dh_lib.c +++ b/lib/libcrypto/dh/dh_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_lib.c,v 1.43 2023/11/29 21:35:57 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.44 2024/03/27 01:22:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -170,9 +170,7 @@ LCRYPTO_ALIAS(DH_free); int DH_up_ref(DH *r) { - int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH); - - return i > 1 ? 1 : 0; + return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH) > 1; } LCRYPTO_ALIAS(DH_up_ref); diff --git a/lib/libcrypto/dsa/dsa_lib.c b/lib/libcrypto/dsa/dsa_lib.c index 65eb65288dd..2727e220f93 100644 --- a/lib/libcrypto/dsa/dsa_lib.c +++ b/lib/libcrypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.46 2023/11/29 21:35:57 tb Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.47 2024/03/27 01:22:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -176,8 +176,7 @@ LCRYPTO_ALIAS(DSA_free); int DSA_up_ref(DSA *r) { - int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA); - return i > 1 ? 1 : 0; + return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA) > 1; } LCRYPTO_ALIAS(DSA_up_ref); diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index dd976898ad0..e959829478f 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.39 2023/11/29 21:35:57 tb Exp $ */ +/* $OpenBSD: ec_key.c,v 1.40 2024/03/27 01:22:30 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -204,8 +204,7 @@ LCRYPTO_ALIAS(EC_KEY_dup); int EC_KEY_up_ref(EC_KEY *r) { - int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC); - return ((i > 1) ? 1 : 0); + return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC) > 1; } LCRYPTO_ALIAS(EC_KEY_up_ref); diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c index b379cddc078..91f4938ec95 100644 --- a/lib/libcrypto/rsa/rsa_lib.c +++ b/lib/libcrypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.49 2023/11/19 15:46:10 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.50 2024/03/27 01:22:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -192,8 +192,7 @@ LCRYPTO_ALIAS(RSA_free); int RSA_up_ref(RSA *r) { - int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA); - return i > 1 ? 1 : 0; + return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA) > 1; } LCRYPTO_ALIAS(RSA_up_ref); diff --git a/lib/libcrypto/x509/x_all.c b/lib/libcrypto/x509/x_all.c index cd6da9f409e..45c527b4189 100644 --- a/lib/libcrypto/x509/x_all.c +++ b/lib/libcrypto/x509/x_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_all.c,v 1.30 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: x_all.c,v 1.31 2024/03/27 01:22:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -535,7 +535,6 @@ LCRYPTO_ALIAS(X509_NAME_digest); int X509_up_ref(X509 *x) { - int i = CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); - return i > 1 ? 1 : 0; + return CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509) > 1; } LCRYPTO_ALIAS(X509_up_ref);