posix.cfg: Added support for drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48 and lcong48 - generate uniformly distributed pseudo-random numbers.

This commit is contained in:
orbitcowboy 2022-04-26 17:24:39 +02:00
parent bfbc7e1549
commit 0d35a60954
2 changed files with 109 additions and 0 deletions

View File

@ -2088,6 +2088,73 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<valid>1:</valid>
</arg>
</function>
<!-- void srand48(long int seedval); -->
<function name="srand48">
<leak-ignore/>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- unsigned short *seed48(unsigned short seed16v[3]); -->
<function name="seed48">
<leak-ignore/>
<use-retval/>
<returnValue type="unsigned short *"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="value" value="3"/>
</arg>
</function>
<!-- long int jrand48(unsigned short xsubi[3]); -->
<function name="jrand48">
<leak-ignore/>
<use-retval/>
<returnValue type="long int"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="value" value="3"/>
</arg>
</function>
<!-- long int nrand48(unsigned short xsubi[3]); -->
<function name="nrand48">
<leak-ignore/>
<use-retval/>
<returnValue type="long int"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="value" value="3"/>
</arg>
</function>
<!-- double erand48(unsigned short xsubi[3]); -->
<function name="erand48">
<leak-ignore/>
<use-retval/>
<returnValue type="double"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="value" value="3"/>
</arg>
</function>
<!-- void lcong48(unsigned short param[7]); -->
<function name="lcong48">
<leak-ignore/>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="value" value="7"/>
</arg>
</function>
<!-- ssize_t read(int fd, void *buf, size_t count); -->
<function name="read">
<leak-ignore/>
@ -3672,6 +3739,13 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<returnValue type="double"/>
<noreturn>false</noreturn>
</function>
<!-- long int lrand48(void); -->
<!-- long int mrand48(void); -->
<function name="lrand48,mrand48">
<use-retval/>
<returnValue type="long int"/>
<noreturn>false</noreturn>
</function>
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/putenv.html -->
<!-- int putenv(char *string); -->
<function name="putenv">

View File

@ -31,6 +31,41 @@
#include <wchar.h>
#include <string.h>
void nullPointer_lcong48(unsigned short param[7])
{
// cppcheck-suppress nullPointer
(void) lcong48(NULL);
return lcong48(param);
}
long int nullPointer_jrand48(unsigned short xsubi[3])
{
// cppcheck-suppress nullPointer
(void) jrand48(NULL);
return jrand48(xsubi);
}
long int nullPointer_nrand48(unsigned short xsubi[3])
{
// cppcheck-suppress nullPointer
(void) nrand48(NULL);
return nrand48(xsubi);
}
double nullPointer_erand48(unsigned short xsubi[3])
{
// cppcheck-suppress nullPointer
(void) erand48(NULL);
return erand48(xsubi);
}
unsigned short *nullPointer_seed48(unsigned short seed16v[3])
{
// cppcheck-suppress nullPointer
(void) seed48(NULL);
return seed48(seed16v);
}
int nullPointer_getlogin_r(char *buf, size_t bufsize)
{
// cppcheck-suppress nullPointer