Skip to content

Commit 0d35a60

Browse files
committed
posix.cfg: Added support for drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48 and lcong48 - generate uniformly distributed pseudo-random numbers.
1 parent bfbc7e1 commit 0d35a60

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

cfg/posix.cfg

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,73 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
20882088
<valid>1:</valid>
20892089
</arg>
20902090
</function>
2091+
<!-- void srand48(long int seedval); -->
2092+
<function name="srand48">
2093+
<leak-ignore/>
2094+
<returnValue type="void"/>
2095+
<arg nr="1" direction="in">
2096+
<not-uninit/>
2097+
</arg>
2098+
</function>
2099+
<!-- unsigned short *seed48(unsigned short seed16v[3]); -->
2100+
<function name="seed48">
2101+
<leak-ignore/>
2102+
<use-retval/>
2103+
<returnValue type="unsigned short *"/>
2104+
<arg nr="1" direction="in">
2105+
<not-null/>
2106+
<not-uninit/>
2107+
<not-bool/>
2108+
<minsize type="value" value="3"/>
2109+
</arg>
2110+
</function>
2111+
<!-- long int jrand48(unsigned short xsubi[3]); -->
2112+
<function name="jrand48">
2113+
<leak-ignore/>
2114+
<use-retval/>
2115+
<returnValue type="long int"/>
2116+
<arg nr="1" direction="in">
2117+
<not-null/>
2118+
<not-uninit/>
2119+
<not-bool/>
2120+
<minsize type="value" value="3"/>
2121+
</arg>
2122+
</function>
2123+
<!-- long int nrand48(unsigned short xsubi[3]); -->
2124+
<function name="nrand48">
2125+
<leak-ignore/>
2126+
<use-retval/>
2127+
<returnValue type="long int"/>
2128+
<arg nr="1" direction="in">
2129+
<not-null/>
2130+
<not-uninit/>
2131+
<not-bool/>
2132+
<minsize type="value" value="3"/>
2133+
</arg>
2134+
</function>
2135+
<!-- double erand48(unsigned short xsubi[3]); -->
2136+
<function name="erand48">
2137+
<leak-ignore/>
2138+
<use-retval/>
2139+
<returnValue type="double"/>
2140+
<arg nr="1" direction="in">
2141+
<not-null/>
2142+
<not-uninit/>
2143+
<not-bool/>
2144+
<minsize type="value" value="3"/>
2145+
</arg>
2146+
</function>
2147+
<!-- void lcong48(unsigned short param[7]); -->
2148+
<function name="lcong48">
2149+
<leak-ignore/>
2150+
<returnValue type="void"/>
2151+
<arg nr="1" direction="in">
2152+
<not-null/>
2153+
<not-uninit/>
2154+
<not-bool/>
2155+
<minsize type="value" value="7"/>
2156+
</arg>
2157+
</function>
20912158
<!-- ssize_t read(int fd, void *buf, size_t count); -->
20922159
<function name="read">
20932160
<leak-ignore/>
@@ -3672,6 +3739,13 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
36723739
<returnValue type="double"/>
36733740
<noreturn>false</noreturn>
36743741
</function>
3742+
<!-- long int lrand48(void); -->
3743+
<!-- long int mrand48(void); -->
3744+
<function name="lrand48,mrand48">
3745+
<use-retval/>
3746+
<returnValue type="long int"/>
3747+
<noreturn>false</noreturn>
3748+
</function>
36753749
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/putenv.html -->
36763750
<!-- int putenv(char *string); -->
36773751
<function name="putenv">

test/cfg/posix.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@
3131
#include <wchar.h>
3232
#include <string.h>
3333

34+
void nullPointer_lcong48(unsigned short param[7])
35+
{
36+
// cppcheck-suppress nullPointer
37+
(void) lcong48(NULL);
38+
return lcong48(param);
39+
}
40+
41+
long int nullPointer_jrand48(unsigned short xsubi[3])
42+
{
43+
// cppcheck-suppress nullPointer
44+
(void) jrand48(NULL);
45+
return jrand48(xsubi);
46+
}
47+
48+
long int nullPointer_nrand48(unsigned short xsubi[3])
49+
{
50+
// cppcheck-suppress nullPointer
51+
(void) nrand48(NULL);
52+
return nrand48(xsubi);
53+
}
54+
55+
double nullPointer_erand48(unsigned short xsubi[3])
56+
{
57+
// cppcheck-suppress nullPointer
58+
(void) erand48(NULL);
59+
return erand48(xsubi);
60+
}
61+
62+
unsigned short *nullPointer_seed48(unsigned short seed16v[3])
63+
{
64+
// cppcheck-suppress nullPointer
65+
(void) seed48(NULL);
66+
return seed48(seed16v);
67+
}
68+
3469
int nullPointer_getlogin_r(char *buf, size_t bufsize)
3570
{
3671
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)