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> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<formatstr/> <formatstr/>
<arg nr="1">
<not-null/>
<minsize type="argvalue" arg="2"/>
<minsize type="strlen" arg="3"/>
</arg>
<arg nr="2"> <arg nr="2">
<not-uninit/> <not-uninit/>
</arg> </arg>

View File

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

View File

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

View File

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