From 1ae7466a2fdd60df6484d8d132d70a044fd58c92 Mon Sep 17 00:00:00 2001 From: miod <> Date: Sat, 12 Jul 2014 16:03:37 +0000 Subject: if (x) FOO_free(x) -> FOO_free(x). Improves readability, keeps the code smaller so that it is warmer in your cache. review & ok deraadt@ --- src/lib/libcrypto/evp/digest.c | 5 ++--- src/lib/libcrypto/evp/evp_pkey.c | 4 ++-- src/lib/libcrypto/evp/pmeth_fn.c | 5 ++--- src/lib/libcrypto/evp/pmeth_gn.c | 5 ++--- src/lib/libcrypto/evp/pmeth_lib.c | 8 +++----- 5 files changed, 11 insertions(+), 16 deletions(-) (limited to 'src/lib/libcrypto/evp') diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c index 9a4b1a6293..d582d7954e 100644 --- a/src/lib/libcrypto/evp/digest.c +++ b/src/lib/libcrypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.21 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: digest.c,v 1.22 2014/07/12 16:03:37 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -358,8 +358,7 @@ EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size); free(ctx->md_data); } - if (ctx->pctx) - EVP_PKEY_CTX_free(ctx->pctx); + EVP_PKEY_CTX_free(ctx->pctx); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_MD we used belongs to an ENGINE, release the diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c index cf7a39be7b..38a324558f 100644 --- a/src/lib/libcrypto/evp/evp_pkey.c +++ b/src/lib/libcrypto/evp/evp_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey.c,v 1.16 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: evp_pkey.c,v 1.17 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -104,7 +104,7 @@ EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8) return pkey; error: - EVP_PKEY_free (pkey); + EVP_PKEY_free(pkey); return NULL; } diff --git a/src/lib/libcrypto/evp/pmeth_fn.c b/src/lib/libcrypto/evp/pmeth_fn.c index c4a53b0d5f..4cf18a0be1 100644 --- a/src/lib/libcrypto/evp/pmeth_fn.c +++ b/src/lib/libcrypto/evp/pmeth_fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_fn.c,v 1.4 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_fn.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -331,8 +331,7 @@ EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer) return -1; } - if (ctx->peerkey) - EVP_PKEY_free(ctx->peerkey); + EVP_PKEY_free(ctx->peerkey); ctx->peerkey = peer; ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer); diff --git a/src/lib/libcrypto/evp/pmeth_gn.c b/src/lib/libcrypto/evp/pmeth_gn.c index 9eb10d4874..29f533625a 100644 --- a/src/lib/libcrypto/evp/pmeth_gn.c +++ b/src/lib/libcrypto/evp/pmeth_gn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_gn.c,v 1.4 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_gn.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -222,7 +222,6 @@ EVP_PKEY_new_mac_key(int type, ENGINE *e, const unsigned char *key, int keylen) goto merr; merr: - if (mac_ctx) - EVP_PKEY_CTX_free(mac_ctx); + EVP_PKEY_CTX_free(mac_ctx); return mac_key; } diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index c9c3444a13..12267a6d93 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_lib.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: pmeth_lib.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -371,10 +371,8 @@ EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) return; if (ctx->pmeth && ctx->pmeth->cleanup) ctx->pmeth->cleanup(ctx); - if (ctx->pkey) - EVP_PKEY_free(ctx->pkey); - if (ctx->peerkey) - EVP_PKEY_free(ctx->peerkey); + EVP_PKEY_free(ctx->pkey); + EVP_PKEY_free(ctx->peerkey); #ifndef OPENSSL_NO_ENGINE if (ctx->engine) /* The EVP_PKEY_CTX we used belongs to an ENGINE, release the -- cgit v1.2.3-55-g6feb