posix.cfg: Improved configuration for close(). Issue a warning in case close is called with a file pointer having a negative value.

This commit is contained in:
orbitcowboy 2019-04-21 12:28:17 +02:00
parent bca2dfb3f4
commit 45a3f679b4
2 changed files with 10 additions and 1 deletions

View File

@ -1114,9 +1114,10 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<function name="close">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1">
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<!-- size_t confstr(int, char *, size_t); -->

View File

@ -215,6 +215,14 @@ void invalidFunctionArg()
usleep(1000000);
}
void invalidFunctionArg_close(int fd)
{
if (fd < 0) {
// cppcheck-suppress invalidFunctionArg
(void)close(fd);
}
}
void uninitvar(int fd)
{
int x1, x2, x3, x4;