diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 4af5564f3..fe86474e5 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -242,21 +242,10 @@ - - - - false - - - - - - - - - + false @@ -266,7 +255,7 @@ - + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 40c8c9001..15227a160 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -62,6 +62,12 @@ void nullPointer(char *p, int fd) // not implemented yet: cppcheck-suppress nullPointer write(fd,NULL,42); write(fd,NULL,0); + // cppcheck-suppress leakReturnValNotUsed + // cppcheck-suppress nullPointer + open(NULL, 0); + // cppcheck-suppress leakReturnValNotUsed + // cppcheck-suppress nullPointer + open(NULL, 0, 0); } void memleak_getaddrinfo() @@ -107,6 +113,20 @@ void resourceLeak_socket(void) // cppcheck-suppress resourceLeak } +void resourceLeak_open1(void) +{ + // cppcheck-suppress unreadVariable + int fd = open("file", O_RDWR | O_CREAT); + // cppcheck-suppress resourceLeak +} + +void resourceLeak_open2(void) +{ + // cppcheck-suppress unreadVariable + int fd = open("file", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + // cppcheck-suppress resourceLeak +} + void noleak(int x, int y, int z) { DIR *p1 = fdopendir(x); @@ -115,6 +135,10 @@ void noleak(int x, int y, int z) closedir(p2); int s = socket(AF_INET,SOCK_STREAM,0); close(s); + int fd1 = open("a", O_RDWR | O_CREAT); + close(fd1); + int fd2 = open("a", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + close(fd2); /* TODO: add configuration for open/fdopen // #2830 int fd = open("path", O_RDONLY);