From 45a3f679b4942fc4332eed6d9965a55ade541983 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sun, 21 Apr 2019 12:28:17 +0200 Subject: [PATCH] posix.cfg: Improved configuration for close(). Issue a warning in case close is called with a file pointer having a negative value. --- cfg/posix.cfg | 3 ++- test/cfg/posix.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 5f7edd788..2c8f930ca 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -1114,9 +1114,10 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s false - + + 0: diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 5eed324be..a7d252dad 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -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;