Skip to content

Commit c7993c3

Browse files
committed
bsd.cfg: Added support for strlcat().
1 parent d412c39 commit c7993c3

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

cfg/bsd.cfg

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,28 @@
135135
</arg>
136136
<leak-ignore/>
137137
</function>
138+
<!-- https://www.freebsd.org/cgi/man.cgi?query=strlcat
139+
size_t strlcat(char *dst, const char *src, size_t size); -->
140+
<function name="strlcat">
141+
<returnValue type="size_t"/>
142+
<noreturn>false</noreturn>
143+
<leak-ignore/>
144+
<arg nr="1">
145+
<not-null/>
146+
<not-uninit/>
147+
<strz/>
148+
<minsize type="argvalue" arg="3"/>
149+
</arg>
150+
<arg nr="2">
151+
<not-null/>
152+
<not-uninit/>
153+
</arg>
154+
<arg nr="3">
155+
<not-uninit/>
156+
<not-bool/>
157+
<valid>0:</valid>
158+
</arg>
159+
</function>
138160
<podtype name="FTS"/>
139161
<podtype name="FTSENT"/>
140162
</def>

test/cfg/bsd.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test library configuration for bsd.cfg
2+
//
3+
// Usage:
4+
// $ cppcheck --library=bsd --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c
5+
// =>
6+
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
7+
//
8+
9+
#include <string.h>
10+
11+
// size_t strlcat(char *dst, const char *src, size_t size);
12+
void uninitvar_strlcat(char *Ct, const char *S, size_t N)
13+
{
14+
char *ct;
15+
char *s;
16+
size_t n;
17+
// cppcheck-suppress uninitvar
18+
(void)strlcat(ct,s,n);
19+
// cppcheck-suppress uninitvar
20+
(void)strlcat(ct,S,N);
21+
// cppcheck-suppress uninitvar
22+
(void)strlcat(Ct,s,N);
23+
// cppcheck-suppress uninitvar
24+
(void)strlcat(Ct,S,n);
25+
26+
// no warning is expected for
27+
(void)strlcat(Ct,S,N);
28+
}

test/cfg/runtests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ${CPPCHECK} ${CPPCHECK_OPT} --library=gnu ${DIR}gnu.c
3131
${CXX} ${CXX_OPT} ${DIR}qt.cpp
3232
${CPPCHECK} --enable=style --enable=information --inconclusive --inline-suppr --error-exitcode=1 --library=qt ${DIR}qt.cpp
3333

34+
# bsd.c
35+
${CPPCHECK} ${CPPCHECK_OPT} --library=bsd ${DIR}bsd.c
36+
3437
# std.c
3538
${CC} ${CC_OPT} ${DIR}std.c
3639
${CPPCHECK} ${CPPCHECK_OPT} ${DIR}std.c

0 commit comments

Comments
 (0)