Skip to content

Commit 521f0ce

Browse files
committed
gnu.cfg: Added nullpointer tests for getopt_long().
1 parent b380fd2 commit 521f0ce

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/cfg/gnu.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#endif
2525
#include <strings.h>
2626
#include <error.h>
27+
#include <getopt.h>
2728

2829
void unreachableCode_error(void) // #11197
2930
{
@@ -33,6 +34,18 @@ void unreachableCode_error(void) // #11197
3334
int i;
3435
}
3536

37+
int nullPointer_getopt_long(int argc, char **argv, const char *optstring,
38+
const struct option *longopts, int *longindex)
39+
{
40+
// cppcheck-suppress nullPointer
41+
(void) getopt_long(argc, argv, NULL, longopts, longindex);
42+
// cppcheck-suppress nullPointer
43+
(void) getopt_long(argc, argv, optstring, NULL, longindex);
44+
// cppcheck-suppress nullPointer
45+
(void) getopt_long(argc, NULL, optstring, longopts, longindex);
46+
return getopt_long(argc, argv, optstring, longopts, longindex);
47+
}
48+
3649
int nullPointer_getservent_r(struct servent *restrict result_buf, char *restrict buf, size_t buflen, struct servent **restrict result)
3750
{
3851
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)