diff options
author | Doug Hogan <[email protected]> | 2019-01-15 08:04:32 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-15 08:38:09 -0800 |
commit | 7cb2e25a026e6d9ff2cdb078504163de5f71c29a (patch) | |
tree | 5e754c51987515e2688d6fb1f7a70512207fe27e /lib/crypto/c_src/rand.c | |
parent | b36527d7bee7c264bfac9b36fd6dc58b2f15a7f0 (diff) | |
download | otp-7cb2e25a026e6d9ff2cdb078504163de5f71c29a.tar.gz otp-7cb2e25a026e6d9ff2cdb078504163de5f71c29a.tar.bz2 otp-7cb2e25a026e6d9ff2cdb078504163de5f71c29a.zip |
Convert argc checks to ASSERTs per PR
Diffstat (limited to 'lib/crypto/c_src/rand.c')
-rw-r--r-- | lib/crypto/c_src/rand.c | 16 |
1 files changed, 8 insertions, 8 deletions
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) |