Running astyle; Improved testing of std::find; std.cfg: Added support for istream::read and ifstream::read.

This commit is contained in:
orbitcowboy 2016-08-25 19:17:07 +02:00
parent b5085db3c8
commit 87409ea6b3
7 changed files with 68 additions and 16 deletions

View File

@ -3989,6 +3989,18 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/>
</arg>
</function>
<!-- istream& read (char* s, streamsize n);
ifstream& read (char* s, streamsize n); -->
<function name="std::istream::read,std::ifstream::read">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-null/>
</arg>
<arg nr="2">
<not-uninit/>
</arg>
</function>
<!-- Not part of standard, but widely supported by runtime libraries. -->
<!-- char * itoa (int value, char * str, int base); -->
<function name="itoa">
@ -4215,6 +4227,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<podtype name="mbstate_t"/>
<podtype name="wint_t"/>
<podtype name="jmp_buf"/>
<podtype name="std::streamsize,streamsize" sign="s"/>
<!-- Fixed width integer sizes, defined in header <stdint.h> -->
<define name="INT8_MIN" value="-128"/>
<define name="INT16_MIN" value="-32768"/>

View File

@ -23,6 +23,8 @@
#include <iostream>
#include <iomanip>
#include <cinttypes>
#include <istream>
#include <fstream>
void bufferAccessOutOfBounds(void)
{
@ -2984,17 +2986,42 @@ void uninitvar_find(std::string s)
(void)s.find(pc,0);
// cppcheck-suppress uninitvar
(void)s.find(pc,pos);
// cppcheck-suppress uninitvar
(void)s.find("test",pos);
// testing of size_t find (char c, size_t pos = 0) const;
char c;
// cppcheck-suppress uninitvar
(void)s.find(c,pos);
/*
// testing of size_t find (const char* pc, size_t pos, size_t n) const;
size_t n;
// cppcheck-suppress uninitvar
(void)s.find(pc,pos,n); // #6991
*/
// cppcheck-suppress uninitvar
(void)s.find("test",pos,n);
// cppcheck-suppress uninitvar
(void)s.find("test",1,n);
// cppcheck-suppress uninitvar
(void)s.find("test",pos,1);
// cppcheck-suppress uninitvar
(void)s.find(pc,1,1);
}
void uninivar_ifstream_read(std::ifstream &f)
{
int size;
char buffer[10];
// cppcheck-suppress uninitvar
f.read(buffer, size);
}
void uninivar_istream_read(std::istream &f)
{
int size;
char buffer[10];
// cppcheck-suppress uninitvar
f.read(buffer, size);
}
void invalidFunctionArgBool_abs(bool b, double x, double y)
@ -3015,6 +3042,18 @@ void ignoredReturnValue_abs(int i)
std::abs(-199);
}
void nullPointer_ifstream_read(std::ifstream &f)
{
// cppcheck-suppress nullPointer
f.read(NULL, 10);
}
void nullPointer_istream_read(std::istream &f)
{
// cppcheck-suppress nullPointer
f.read(NULL, 10);
}
void nullPointer_asctime(void)
{
struct tm *tm = 0;