RE: [PATCH 04/11] include support for a simple pseudo number generator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sascha Hauer wrote...

> +#define RAND_MAX 32767
> +
> +/* return a pseudo-random integer in the range [0, RAND_MAX] */
> +unsigned int rand(void);

*Snip*

> +unsigned int rand(void)
> +{
> +	random_seed = random_seed * 1103515245 + 12345;
> +	return (random_seed / 65536) % 32768;
> +}

The return value on this function seems wrong as it will always return a
value between 0 and 32767 irrespective of what RAND_MAX is set to which
doesn't agree with the comment on the function prototype.

Although it may just be me being dim as my hayfever is driving me mad today
:-)

A.



_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux