From 3f5c10515649b6925d063ae6e4a1eb3ba0abd8e5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 1 Dec 2012 18:44:57 +0000 Subject: [PATCH] Another random number generator update git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5406 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/drivers/lcd/ug-2864ambag01.c | 2 +- nuttx/libc/stdlib/lib_rand.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nuttx/drivers/lcd/ug-2864ambag01.c b/nuttx/drivers/lcd/ug-2864ambag01.c index e133f39010..2a47b38eb7 100644 --- a/nuttx/drivers/lcd/ug-2864ambag01.c +++ b/nuttx/drivers/lcd/ug-2864ambag01.c @@ -970,7 +970,7 @@ static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contras */ #if CONFIG_LCD_MAXCONTRAST != 255 - newcontrast = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST; + scaled = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST; #else scaled = contrast; #endif diff --git a/nuttx/libc/stdlib/lib_rand.c b/nuttx/libc/stdlib/lib_rand.c index 465cce47f8..bbefaee5d0 100644 --- a/nuttx/libc/stdlib/lib_rand.c +++ b/nuttx/libc/stdlib/lib_rand.c @@ -175,13 +175,13 @@ static inline void fgenerate2(void) unsigned long randint; /* Second order congruential generator. One may be added to the result of the - * generated value to avoid the value zero (I am not sure if this is necessor + * generated value to avoid the value zero (I am not sure if this is necessary * for higher order random number generators or how this may effect the quality * of the generated numbers). */ randint = (RND2_CONSTK1 * g_randint1 + - RND2_CONSTK2 * g_randint2) % RND2_CONSTP + 1; + RND2_CONSTK2 * g_randint2) % RND2_CONSTP; g_randint2 = g_randint1; g_randint1 = (randint == 0 ? 1 : randint); @@ -208,14 +208,14 @@ static inline void fgenerate3(void) unsigned long randint; /* Third order congruential generator. One may be added to the result of the - * generated value to avoid the value zero (I am not sure if this is necessor + * generated value to avoid the value zero (I am not sure if this is necessary * for higher order random number generators or how this may effect the quality * of the generated numbers). */ randint = (RND3_CONSTK1 * g_randint1 + RND3_CONSTK2 * g_randint2 + - RND3_CONSTK2 * g_randint3) % RND3_CONSTP + 1; + RND3_CONSTK2 * g_randint3) % RND3_CONSTP; g_randint3 = g_randint2; g_randint2 = g_randint1;