[Pcsclite-cvs-commit] r6319 - /trunk/PCSC/src/sys_unix.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jun 5 08:59:09 UTC 2012
Author: rousseau
Date: Tue Jun 5 08:59:08 2012
New Revision: 6319
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6319
Log:
SYS_RandomInt(): extend range if fEnd == -1
If fEnd parameter is set to -1 then the result of rand() is not
truncated. This is usefull to get 32-bits of random with no constraint
on the values.
Modified:
trunk/PCSC/src/sys_unix.c
Modified: trunk/PCSC/src/sys_unix.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/sys_unix.c?rev=6319&op=diff
==============================================================================
--- trunk/PCSC/src/sys_unix.c (original)
+++ trunk/PCSC/src/sys_unix.c Tue Jun 5 08:59:08 2012
@@ -86,7 +86,11 @@
iInitialized = 1;
}
- iRandNum = ((rand()+0.0)/RAND_MAX * (fEnd - fStart)) + fStart;
+ if (-1 == fEnd)
+ /* full int range */
+ iRandNum = rand();
+ else
+ iRandNum = ((rand()+0.0)/RAND_MAX * (fEnd - fStart)) + fStart;
return iRandNum;
}
More information about the Pcsclite-cvs-commit
mailing list