From 521f0ce72011e332ae9e77921e5ff310e11b1766 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 21 Dec 2022 17:06:08 +0100 Subject: [PATCH] gnu.cfg: Added nullpointer tests for getopt_long(). --- test/cfg/gnu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index f8ce29abd..9c4b20369 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -24,6 +24,7 @@ #endif #include #include +#include void unreachableCode_error(void) // #11197 { @@ -33,6 +34,18 @@ void unreachableCode_error(void) // #11197 int i; } +int nullPointer_getopt_long(int argc, char **argv, const char *optstring, + const struct option *longopts, int *longindex) +{ + // cppcheck-suppress nullPointer + (void) getopt_long(argc, argv, NULL, longopts, longindex); + // cppcheck-suppress nullPointer + (void) getopt_long(argc, argv, optstring, NULL, longindex); + // cppcheck-suppress nullPointer + (void) getopt_long(argc, NULL, optstring, longopts, longindex); + return getopt_long(argc, argv, optstring, longopts, longindex); +} + int nullPointer_getservent_r(struct servent *restrict result_buf, char *restrict buf, size_t buflen, struct servent **restrict result) { // cppcheck-suppress nullPointer