From bd1d8ea7b845a013adc58f6b55bfb15a0c05447c Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Mon, 7 Feb 2022 13:58:38 +0100 Subject: [PATCH] posix.cfg: Improved configuration of lseek(). --- cfg/posix.cfg | 1 + test/cfg/posix.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index f28469747..c7f37f50b 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -3394,6 +3394,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + 0:2 diff --git a/test/cfg/posix.c b/test/cfg/posix.c index cff20eaf5..5cc3a0360 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -29,6 +29,26 @@ #include #include +void invalidFunctionArg_lseek(int fd, off_t offset, int origin) +{ + // cppcheck-suppress invalidFunctionArg + (void)lseek(-1, offset, SEEK_SET); + // cppcheck-suppress invalidFunctionArg + (void)lseek(fd, offset, -1); + // cppcheck-suppress invalidFunctionArg + (void)lseek(fd, offset, 3); + // cppcheck-suppress invalidFunctionArg + (void)lseek(fd, offset, 42+SEEK_SET); + // cppcheck-suppress invalidFunctionArg + (void)lseek(fd, offset, SEEK_SET+42); + // No warning is expected for + (void)lseek(0, offset, origin); + (void)lseek(fd, offset, origin); + (void)lseek(fd, offset, SEEK_SET); + (void)lseek(fd, offset, SEEK_CUR); + (void)lseek(fd, offset, SEEK_END); +} + void invalidFunctionArg_fseeko(FILE* stream, off_t offset, int origin) { // cppcheck-suppress invalidFunctionArg