From adc780e8b1a2c9fd555f6435de851ed0ab609094 Mon Sep 17 00:00:00 2001 From: Doug Hogan Date: Sat, 5 Jan 2019 12:36:29 -0800 Subject: Revamp init_hmac_ctx() --- lib/crypto/c_src/hmac.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/crypto') diff --git a/lib/crypto/c_src/hmac.c b/lib/crypto/c_src/hmac.c index 08d9049caa..a5ff35c706 100644 --- a/lib/crypto/c_src/hmac.c +++ b/lib/crypto/c_src/hmac.c @@ -37,11 +37,14 @@ int init_hmac_ctx(ErlNifEnv *env) { (ErlNifResourceDtor*) hmac_context_dtor, ERL_NIF_RT_CREATE|ERL_NIF_RT_TAKEOVER, NULL); - if (hmac_context_rtype == NULL) { - PRINTF_ERR0("CRYPTO: Could not open resource type 'hmac_context'"); - return 0; - } + if (hmac_context_rtype == NULL) + goto err; + return 1; + + err: + PRINTF_ERR0("CRYPTO: Could not open resource type 'hmac_context'"); + return 0; } ERL_NIF_TERM hmac_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) -- cgit v1.2.3