summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-05-02 18:30:00 +0100
committerDr. Stephen Henson <steve@openssl.org>2015-05-03 12:53:08 +0100
commitb6eb9827a6866981c08cc9613ca8b4a648894fb1 (patch)
treec5a6351461d8be964bc1f31fa2e34c4ebb7cfafd /crypto/rand
parent31ff45aa975acb43f1da20e714eadf4649655714 (diff)
Add OSSL_NELEM macro.
Add OSSL_NELEM macro to e_os.h to determine the number of elements in an array. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/rand_unix.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
index 732ba3b31b..4332270004 100644
--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -250,7 +250,7 @@ int RAND_poll(void)
# endif
# ifdef DEVRANDOM
static const char *randomfiles[] = { DEVRANDOM };
- struct stat randomstats[sizeof(randomfiles) / sizeof(randomfiles[0])];
+ struct stat randomstats[OSSL_NELEM(randomfiles)];
int fd;
unsigned int i;
# endif
@@ -267,8 +267,7 @@ int RAND_poll(void)
* out of random entries.
*/
- for (i = 0; (i < sizeof(randomfiles) / sizeof(randomfiles[0])) &&
- (n < ENTROPY_NEEDED); i++) {
+ for (i = 0; (i < OSSL_NELEM(randomfiles)) && (n < ENTROPY_NEEDED); i++) {
if ((fd = open(randomfiles[i], O_RDONLY
# ifdef O_NONBLOCK
| O_NONBLOCK