gnu/bsd.cfg: Cleanup redundant configuration for timercmp() and add more tests.

This commit is contained in:
orbitcowboy 2019-09-10 11:51:47 +02:00
parent afe05d019c
commit da29a1f56b
4 changed files with 41 additions and 37 deletions

View File

@ -39,24 +39,6 @@
</arg> </arg>
</function> </function>
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)--> <!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
<function name="timercmp">
<noreturn>false</noreturn>
<leak-ignore/>
<use-retval/>
<returnValue type="int"/>
<arg nr="1" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
<define name="timercmp(a,b,CMP)" value="(((a)-&gt;tv_sec == (b)-&gt;tv_sec) ? ((a)-&gt;tv_usec CMP (b)-&gt;tv_usec) : ((a)-&gt;tv_sec CMP (b)-&gt;tv_sec))"/> <define name="timercmp(a,b,CMP)" value="(((a)-&gt;tv_sec == (b)-&gt;tv_sec) ? ((a)-&gt;tv_usec CMP (b)-&gt;tv_usec) : ((a)-&gt;tv_sec CMP (b)-&gt;tv_sec))"/>
<!-- https://www.freebsd.org/cgi/man.cgi?query=fts&sektion=3 --> <!-- https://www.freebsd.org/cgi/man.cgi?query=fts&sektion=3 -->
<!-- FTS * fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT * const *, const FTSENT * const *)); --> <!-- FTS * fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT * const *, const FTSENT * const *)); -->

View File

@ -128,24 +128,6 @@
</arg> </arg>
</function> </function>
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)--> <!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
<function name="timercmp">
<noreturn>false</noreturn>
<leak-ignore/>
<use-retval/>
<returnValue type="int"/>
<arg nr="1" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int timercmp(struct timeval *a, struct timeval *b, CMP)-->
<define name="timercmp(a,b,CMP)" value="(((a)-&gt;tv_sec == (b)-&gt;tv_sec) ? ((a)-&gt;tv_usec CMP (b)-&gt;tv_usec) : ((a)-&gt;tv_sec CMP (b)-&gt;tv_sec))"/> <define name="timercmp(a,b,CMP)" value="(((a)-&gt;tv_sec == (b)-&gt;tv_sec) ? ((a)-&gt;tv_usec CMP (b)-&gt;tv_usec) : ((a)-&gt;tv_sec CMP (b)-&gt;tv_sec))"/>
<!-- int __builtin_types_compatible_p (type1, type2) --> <!-- int __builtin_types_compatible_p (type1, type2) -->
<function name="__builtin_types_compatible_p"> <function name="__builtin_types_compatible_p">

View File

@ -22,6 +22,26 @@ void verify_timercmp(struct timeval t)
(void)timercmp(&t, &t, >); (void)timercmp(&t, &t, >);
} }
// False negative: #9346
void uninitvar_timercmp(struct timeval t)
{
struct timeval uninit;
(void)timercmp(&t, &uninit, <);
(void)timercmp(&uninit, &t, <=);
(void)timercmp(&uninit, &uninit, ==);
}
void nullPointer_timercmp(struct timeval t)
{
struct timeval *p=0;
// cppcheck-suppress nullPointer
(void)timercmp(&t, p, <);
// cppcheck-suppress nullPointer
(void)timercmp(p, &t, <=);
// cppcheck-suppress nullPointer
(void)timercmp(p, p, ==);
}
// size_t strlcat(char *dst, const char *src, size_t size); // size_t strlcat(char *dst, const char *src, size_t size);
void uninitvar_strlcat(char *Ct, const char *S, size_t N) void uninitvar_strlcat(char *Ct, const char *S, size_t N)
{ {

View File

@ -18,7 +18,7 @@
#endif #endif
// #9323, #9331 // #9323, #9331
void verify_timercmp(struct timeval t) void syntaxError_timercmp(struct timeval t)
{ {
(void)timercmp(&t, &t, <); (void)timercmp(&t, &t, <);
(void)timercmp(&t, &t, <=); (void)timercmp(&t, &t, <=);
@ -28,6 +28,26 @@ void verify_timercmp(struct timeval t)
(void)timercmp(&t, &t, >); (void)timercmp(&t, &t, >);
} }
// False negative: #9346
void uninitvar_timercmp(struct timeval t)
{
struct timeval uninit;
(void)timercmp(&t, &uninit, <);
(void)timercmp(&uninit, &t, <=);
(void)timercmp(&uninit, &uninit, ==);
}
void nullPointer_timercmp(struct timeval t)
{
struct timeval *p=0;
// cppcheck-suppress nullPointer
(void)timercmp(&t, p, <);
// cppcheck-suppress nullPointer
(void)timercmp(p, &t, <=);
// cppcheck-suppress nullPointer
(void)timercmp(p, p, ==);
}
// Declaration necessary because there is no specific / portable header. // Declaration necessary because there is no specific / portable header.
extern void *xcalloc(size_t nmemb, size_t size); extern void *xcalloc(size_t nmemb, size_t size);
extern void *xmalloc(size_t size); extern void *xmalloc(size_t size);