Skip to content

Commit d075cba

Browse files
committed
posix.cfg: Ensure null pointer input is correctly handled for bcmp().
1 parent 7cbdea9 commit d075cba

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/cfg/posix.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,19 @@ int nullPointer_strncasecmp(char *a, char *b, size_t n)
236236
return strncasecmp(NULL, b, n);
237237
}
238238

239+
int nullPointer_bcmp(const void *a, const void *b, size_t n)
240+
{
241+
// No nullPointer warning shall be shown:
242+
// cppcheck-suppress bcmpCalled
243+
(void) bcmp(a, b, n);
244+
// cppcheck-suppress nullPointer
245+
// cppcheck-suppress bcmpCalled
246+
(void) bcmp(a, NULL, n);
247+
// cppcheck-suppress nullPointer
248+
// cppcheck-suppress bcmpCalled
249+
return bcmp(NULL, b, n);
250+
}
251+
239252
char * nullPointer_stpcpy(char *src, char *dest)
240253
{
241254
// No warning shall be shown:

0 commit comments

Comments
 (0)