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"> <function name="close">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<returnValue type="int"/> <returnValue type="int"/>
<arg nr="1"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-bool/> <not-bool/>
<valid>0:</valid>
</arg> </arg>
</function> </function>
<!-- size_t confstr(int, char *, size_t); --> <!-- size_t confstr(int, char *, size_t); -->

View File

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