From 58b3d75b6250bfab278e9369c3c030ba78dc7185 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Tue, 20 Nov 2018 08:32:54 +0100 Subject: [PATCH] std.cfg: Added invalidFunctionArg cfg for strchr(). --- cfg/std.cfg | 1 + test/cfg/std.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 82facb1f4..ad3e12ead 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4546,6 +4546,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + 0:255 diff --git a/test/cfg/std.c b/test/cfg/std.c index faecabce7..fcb3e4f31 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -2901,6 +2901,19 @@ void uninitvar_strchr(void) (void)strchr(cs,c); } +void invalidFunctionArg_strchr(char *cs, int c) +{ + // cppcheck-suppress invalidFunctionArg + (void)strchr(cs,-1); + + // No warning shall be issued for + (void)strchr(cs, 0); + (void)strchr(cs, 255); + + // cppcheck-suppress invalidFunctionArg + (void)strchr(cs, 256); +} + void uninitvar_wcschr(void) { wchar_t *cs;