From 7cb2e25a026e6d9ff2cdb078504163de5f71c29a Mon Sep 17 00:00:00 2001 From: Doug Hogan Date: Tue, 15 Jan 2019 08:04:32 -0800 Subject: Convert argc checks to ASSERTs per PR --- lib/crypto/c_src/rand.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/crypto/c_src/rand.c') diff --git a/lib/crypto/c_src/rand.c b/lib/crypto/c_src/rand.c index cf793a7aac..3812ae0991 100644 --- a/lib/crypto/c_src/rand.c +++ b/lib/crypto/c_src/rand.c @@ -27,8 +27,8 @@ ERL_NIF_TERM strong_rand_bytes_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM unsigned char* data; ERL_NIF_TERM ret; - if (argc != 1) - goto bad_arg; + ASSERT(argc == 1); + if (!enif_get_uint(env, argv[0], &bytes)) goto bad_arg; if (bytes > INT_MAX) @@ -54,8 +54,8 @@ ERL_NIF_TERM strong_rand_range_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM BIGNUM *bn_range = NULL, *bn_rand = NULL; ERL_NIF_TERM ret; - if (argc != 1) - goto bad_arg; + ASSERT(argc == 1); + if (!get_bn_from_bin(env, argv[0], &bn_range)) goto bad_arg; @@ -89,8 +89,8 @@ ERL_NIF_TERM rand_uniform_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[ int dlen; ERL_NIF_TERM ret; - if (argc != 2) - goto bad_arg; + ASSERT(argc == 2); + if (!get_bn_from_mpint(env, argv[0], &bn_from)) goto bad_arg; if (!get_bn_from_mpint(env, argv[1], &bn_rand)) @@ -134,8 +134,8 @@ ERL_NIF_TERM rand_seed_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Seed) */ ErlNifBinary seed_bin; - if (argc != 1) - goto bad_arg; + ASSERT(argc == 1); + if (!enif_inspect_binary(env, argv[0], &seed_bin)) goto bad_arg; if (seed_bin.size > INT_MAX) -- cgit v1.2.3