diff --git a/drivers/dev_urandom.c b/drivers/dev_urandom.c index 6a5e48a932..0c85d8cfa4 100644 --- a/drivers/dev_urandom.c +++ b/drivers/dev_urandom.c @@ -138,20 +138,20 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, /* Align buffer pointer to 4-byte boundry */ - if ((unsigned)buffer & 0x03) + if (((unsigned)buffer & 0x03) != 0) { /* Generate a pseudo random number */ rnd = xorshift128(); - while ((unsigned)buffer & 0x03) + while (((unsigned)buffer & 0x03) != 0) { if (n <= 0) { return len; } - *buffer++ = rnd & 0xFF; + *buffer++ = rnd & 0xff; rnd >>= 8; --n; } diff --git a/libc/stdlib/Make.defs b/libc/stdlib/Make.defs index 625712e91e..ecf8f5fefa 100644 --- a/libc/stdlib/Make.defs +++ b/libc/stdlib/Make.defs @@ -37,7 +37,7 @@ CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c -CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c +CSRCS += lib_bsearch.c lib_srand.c lib_qsort.c CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c CSRCS += lib_strtod.c lib_checkbase.c diff --git a/libc/stdlib/lib_rand.c b/libc/stdlib/lib_srand.c similarity index 96% rename from libc/stdlib/lib_rand.c rename to libc/stdlib/lib_srand.c index 453a4537a0..726b4ab0f7 100644 --- a/libc/stdlib/lib_rand.c +++ b/libc/stdlib/lib_srand.c @@ -1,7 +1,7 @@ /**************************************************************************** - * libc/stdlib/lib_rand.c + * libc/stdlib/lib_srand.c * - * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2011, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -70,7 +70,7 @@ * Private Function Prototypes ****************************************************************************/ -static unsigned int nrand(unsigned int nLimit); +static unsigned int nrand(unsigned int limit); /* First order congruential generators */ @@ -111,7 +111,7 @@ static unsigned long g_randint3; * Private Functions ****************************************************************************/ -static unsigned int nrand(unsigned int nLimit) +static unsigned int nrand(unsigned int limit) { unsigned long result; double_t ratio; @@ -132,9 +132,9 @@ static unsigned int nrand(unsigned int nLimit) /* Then, produce the return-able value */ - result = (unsigned long)(((double_t)nLimit) * ratio); + result = (unsigned long)(((double_t)limit) * ratio); } - while (result >= (unsigned long)nLimit); + while (result >= (unsigned long)limit); return (unsigned int)result; }