std.cfg: snprintf(NULL,0,) is legal. Fix some testcases in test/cfg as well

This commit is contained in:
Alexander Mai 2015-02-22 14:25:25 +01:00
parent d4fa656e58
commit fd7d29447d
4 changed files with 6 additions and 11 deletions

View File

@ -5298,11 +5298,6 @@
<noreturn>false</noreturn>
<leak-ignore/>
<formatstr/>
<arg nr="1">
<not-null/>
<minsize type="argvalue" arg="2"/>
<minsize type="strlen" arg="3"/>
</arg>
<arg nr="2">
<not-uninit/>
</arg>

View File

@ -2,5 +2,5 @@
int main()
{
char str[5];
snprintf(str, 10, "%s", "0123456789abcdef");
strcpy(str, "0123456789abcdef");
}

View File

@ -143,9 +143,6 @@ void uninitvar(int fd) {
pattern="";
// cppcheck-suppress uninitvar
regcomp(&reg, pattern, cflags);
cflags=42;
// cppcheck-suppress uninitvar
regcomp(&reg, pattern, cflags);
}
void uninitvar_types(void) {

View File

@ -21,8 +21,7 @@ void bufferAccessOutOf(void) {
// cppcheck-suppress bufferAccessOutOfBounds
sprintf(a, "ab%s", "cde");
snprintf(a, 5, "abcde%i", 1);
// cppcheck-suppress bufferAccessOutOfBounds
snprintf(a, 6, "abcde%i", 1);
snprintf(a, 6, "abcde%i", 1); //TODO: cppcheck-suppress bufferAccessOutOfBounds
strcpy(a,"abcd");
// cppcheck-suppress bufferAccessOutOfBounds
strcpy(a, "abcde");
@ -126,6 +125,10 @@ void nullpointer(int value){
strxfrm(0,"foo",0);
// TODO: error message
strxfrm(0,"foo",42);
snprintf(NULL, 0, "someformatstring"); // legal
// cppcheck-suppress nullPointer
snprintf(NULL, 42, "someformatstring"); // not legal
}
void nullpointerMemchr1(char *p, char *s) {