std.cfg: Improved configuration of qsort().
This commit is contained in:
parent
6a657865eb
commit
0ec2d5f40d
|
@ -4340,6 +4340,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<arg nr="1" direction="inout">
|
||||
<not-null/>
|
||||
<not-uninit/>
|
||||
<minsize type="argvalue" arg="2"/>
|
||||
</arg>
|
||||
<arg nr="2" direction="in">
|
||||
<not-uninit/>
|
||||
|
@ -4352,6 +4353,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<arg nr="4" direction="in">
|
||||
<not-null/>
|
||||
<not-uninit/>
|
||||
<not-bool/>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- int putc(int c, FILE *stream); -->
|
||||
|
|
|
@ -26,6 +26,19 @@
|
|||
#include <inttypes.h>
|
||||
#include <float.h>
|
||||
|
||||
|
||||
int qsort_cmpfunc (const void * a, const void * b) {
|
||||
return (*(int*)a - *(int*)b);
|
||||
}
|
||||
void nullPointer_qsort(void *base, size_t n, size_t size, int (*cmp)(const void *, const void *))
|
||||
{
|
||||
// cppcheck-suppress nullPointer
|
||||
qsort(NULL, n, size, qsort_cmpfunc);
|
||||
// cppcheck-suppress nullPointer
|
||||
qsort(base, n, size, NULL);
|
||||
qsort(base, n, size, qsort_cmpfunc);
|
||||
}
|
||||
|
||||
// As with all bounds-checked functions, localtime_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including time.h.
|
||||
#ifdef __STDC_LIB_EXT1__
|
||||
void uninitvar_localtime_s(const time_t *restrict time, struct tm *restrict result)
|
||||
|
|
|
@ -32,6 +32,18 @@
|
|||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
int qsort_cmpfunc (const void * a, const void * b) {
|
||||
return (*static_cast<const int*>(a) - *static_cast<const int*>(b));
|
||||
}
|
||||
void nullPointer_qsort(void *base, std::size_t n, std::size_t size, int (*cmp)(const void *, const void *))
|
||||
{
|
||||
// cppcheck-suppress nullPointer
|
||||
std::qsort(nullptr, n, size, qsort_cmpfunc);
|
||||
// cppcheck-suppress nullPointer
|
||||
std::qsort(base, n, size, nullptr);
|
||||
std::qsort(base, n, size, qsort_cmpfunc);
|
||||
}
|
||||
|
||||
void *bufferAccessOutOfBounds_memchr(void *s, int c, size_t n)
|
||||
{
|
||||
char buf[42]={0};
|
||||
|
|
Loading…
Reference in New Issue