posix.cfg: Fixed FP bufferOverlap-warning of bcopy() and added more tests.

This commit is contained in:
orbitcowboy 2022-04-21 08:31:22 +02:00
parent 1fb1b22bae
commit dad1a68e51
2 changed files with 15 additions and 3 deletions

View File

@ -3935,11 +3935,11 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<warn severity="style" reason="Obsolescent" alternatives="scalbln,scalblnf,scalbln,scalbn,scalbnf,scalbnl"/>
</function>
<!-- https://man7.org/linux/man-pages/man3/bcopy.3.html -->
<!-- void bcopy(const void *s1, void *s2, size_t n); -->
<function name="bcopy">
<noreturn>false</noreturn>
<leak-ignore/>
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>

View File

@ -300,8 +300,20 @@ void overlappingWriteFunction_bcopy(char *buf, const size_t count)
// cppcheck-suppress bcopyCalled
bcopy(&buf[0], &buf[3], 3U); // no-overlap
// cppcheck-suppress bcopyCalled
// cppcheck-suppress overlappingWriteFunction
bcopy(&buf[0], &buf[3], 4U);
bcopy(&buf[0], &buf[3], 4U); // The result is correct, even when both areas overlap.
}
void nullPointer_bcopy(const void *src, void *dest, size_t n)
{
// No warning shall be shown:
// cppcheck-suppress bcopyCalled
bcopy(src, dest, n);
// cppcheck-suppress bcopyCalled
// cppcheck-suppress nullPointer
bcopy(NULL, dest, n);
// cppcheck-suppress bcopyCalled
// cppcheck-suppress nullPointer
bcopy(src, NULL, n);
}
void overlappingWriteFunction_memccpy(unsigned char *src, unsigned char *dest, int c, size_t count)