aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorDoug Hogan <[email protected]>2019-01-07 06:45:49 -0800
committerDoug Hogan <[email protected]>2019-01-08 01:11:57 -0800
commitf16e0061a9bdbab39bc25781efbae736710c76af (patch)
tree9e0658dfa0410ec244ecd5c8803a0227f5f70950 /lib/crypto
parentd444902aae3507b0f1256e4b3e0c7993f3da3b68 (diff)
downloadotp-f16e0061a9bdbab39bc25781efbae736710c76af.tar.gz
otp-f16e0061a9bdbab39bc25781efbae736710c76af.tar.bz2
otp-f16e0061a9bdbab39bc25781efbae736710c76af.zip
Revamp engine_init_nif()
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/c_src/engine.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/crypto/c_src/engine.c b/lib/crypto/c_src/engine.c
index 2384235a1e..1398e315aa 100644
--- a/lib/crypto/c_src/engine.c
+++ b/lib/crypto/c_src/engine.c
@@ -167,21 +167,22 @@ ERL_NIF_TERM engine_by_id_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[
ERL_NIF_TERM engine_init_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Engine) */
#ifdef HAS_ENGINE_SUPPORT
- ERL_NIF_TERM ret = atom_ok;
struct engine_ctx *ctx;
// Get Engine
- if (!enif_get_resource(env, argv[0], engine_ctx_rtype, (void**)&ctx)) {
- PRINTF_ERR0("engine_init_nif Leaved: Parameter not an engine resource object");
- return enif_make_badarg(env);
- }
- if (!ENGINE_init(ctx->engine)) {
- //ERR_print_errors_fp(stderr);
- PRINTF_ERR0("engine_init_nif Leaved: {error, engine_init_failed}");
+ if (argc != 1)
+ goto bad_arg;
+ if (!enif_get_resource(env, argv[0], engine_ctx_rtype, (void**)&ctx))
+ goto bad_arg;
+
+ if (!ENGINE_init(ctx->engine))
return enif_make_tuple2(env, atom_error, atom_engine_init_failed);
- }
- return ret;
+ return atom_ok;
+
+ bad_arg:
+ return enif_make_badarg(env);
+
#else
return atom_notsup;
#endif