Added files from local repository.

This commit is contained in:
Daniel Marjamäki 2007-05-07 17:31:35 +00:00
commit 507c9f9f64
43 changed files with 1426 additions and 0 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
checkcode.exe: main.cpp
gxx -Wall -pedantic -g -o checkcode.exe main.cpp

1104
main.cpp Normal file

File diff suppressed because it is too large Load Diff

15
runall.bat Normal file
View File

@ -0,0 +1,15 @@
@ECHO OFF
REM Test the 'checkcode' program
date /t > report.txt
time /t >> report.txt
FOR /D %%s IN (test*) DO (
checkcode %%s\%%s.cpp 2> %%s\out.msg
hydfc %%s\err.msg %%s\out.msg >> report.txt
)
type report.txt

0
testclass1/err.msg Normal file
View File

View File

@ -0,0 +1,8 @@
// No constructor
// uninitialized member variable: 'i'
class clKalle
{
public:
int i;
};

0
testclass10/err.msg Normal file
View File

View File

@ -0,0 +1,15 @@
class clKalle
{
private:
int i;
public:
clKalle();
};
clKalle::clKalle() : i(0)
{
}

0
testclass2/err.msg Normal file
View File

11
testclass2/testclass2.cpp Normal file
View File

@ -0,0 +1,11 @@
// uninitialized member variable: 'i'
class clKalle
{
public:
clKalle()
{
}
int i;
};

0
testclass4/err.msg Normal file
View File

10
testclass4/testclass4.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "testclass4.h"
clKalle::clKalle()
{
i = ds23;
}

8
testclass4/testclass4.h Normal file
View File

@ -0,0 +1,8 @@
class clKalle
{
public:
int i;
clKalle();
};

1
testclass5/err.msg Normal file
View File

@ -0,0 +1 @@
Class 'clKalle', unused private function: 'f'

21
testclass5/testclass5.cpp Normal file
View File

@ -0,0 +1,21 @@
// Unused private function..
class clKalle
{
private:
void f();
void g();
public:
clKalle();
};
clKalle::clKalle()
{
g();
}
void clKalle::f()
{
}

2
testclass6/err.msg Normal file
View File

@ -0,0 +1,2 @@
[testclass6\testclass6.h:3]: Found implementation in header
[testclass6\testclass6.cpp:2]: The included header 'testclass6\testclass6.h' is not needed

View File

@ -0,0 +1,8 @@
#include "testclass6.h"
void clBertil::g()
{
}

7
testclass6/testclass6.h Normal file
View File

@ -0,0 +1,7 @@
class clKalle()
{
private:
void f();
};

0
testclass7/err.msg Normal file
View File

21
testclass7/testclass7.cpp Normal file
View File

@ -0,0 +1,21 @@
// Initializing class variables through a 'Clear' function
class clKalle
{
private:
int i;
public:
clKalle();
void Clear();
};
clKalle::clKalle()
{
Clear();
}
void clKalle::Clear()
{
i = 123;
}

0
testclass8/err.msg Normal file
View File

14
testclass8/testclass8.cpp Normal file
View File

@ -0,0 +1,14 @@
class clKalle
{
private:
std::vector<int> ints;
public:
clKalle();
};
clKalle::clKalle()
{
ints.clear();
}

2
testclass9/err.msg Normal file
View File

@ -0,0 +1,2 @@
Uninitialized member variable 'clKalle::rec3'
Uninitialized member variable 'clKalle::rec1'

33
testclass9/testclass9.cpp Normal file
View File

@ -0,0 +1,33 @@
// A struct must be initialized whenever it's used.
// But a class is supposed to have a constructor that
// performs the initialization.
struct rec
{
int a;
int b;
};
class clRec
{
public:
int a;
int b;
rec2();
};
class clKalle
{
private:
rec rec1;
clRec rec2;
clRec *rec3;
public:
clKalle();
};
clKalle::clKalle()
{
}

1
testdelete1/err.msg Normal file
View File

@ -0,0 +1 @@
[testdelete1\testdelete1.cpp:6]: Redundant condition. It is allowed to deallocate a NULL pointer, so it is safe to remove the 'if(..)'.

View File

@ -0,0 +1,8 @@
void f()
{
if (p)
delete p;
}

0
testfunc2/err.msg Normal file
View File

8
testfunc2/testfunc2.cpp Normal file
View File

@ -0,0 +1,8 @@
void foo(int i)
{
if (ab)
{
i = 4;
}
}

0
testfunc3/err.msg Normal file
View File

28
testfunc3/testfunc3.cpp Normal file
View File

@ -0,0 +1,28 @@
class ITEM
{
public:
void CountIO( int &noIn, int &noOut ) const;
};
void ITEM::CountIO( int &noIn, int &noOut ) const
{
noIn = 0;
noOut = 0;
}

3
testh1/err.msg Normal file
View File

@ -0,0 +1,3 @@
[testh1\testh1.h:5]: Found implementation in header
[testh1\testh1.h:11]: Found implementation in header
[testh1\testh1.cpp:2]: The included header 'testh1\testh1.h' is not needed

2
testh1/testh1.cpp Normal file
View File

@ -0,0 +1,2 @@
#include "testh1.h"

14
testh1/testh1.h Normal file
View File

@ -0,0 +1,14 @@
// This is a header so there should be no implementation here..
void f()
{ }
class clKalle
{
public:
clKalle()
{ }
};

0
testh2/emptyh.h Normal file
View File

2
testh2/err.msg Normal file
View File

@ -0,0 +1,2 @@
[testh2\testh2.cpp:2]: The included header 'testh2\testh2.h' is not needed
[testh2\testh2.h:2]: The included header 'testh2\emptyh.h' is not needed

4
testh2/testh2.cpp Normal file
View File

@ -0,0 +1,4 @@
#include "testh2.h"

7
testh2/testh2.h Normal file
View File

@ -0,0 +1,7 @@
#include "emptyh.h"
class clKalle
{
};

0
testh5/err.msg Normal file
View File

8
testh5/testh5.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "testh5.h"
void f(E1 e1)
{
}

4
testh5/testh5.h Normal file
View File

@ -0,0 +1,4 @@
enum E1 {a,b,c};

2
testmemset1/err.msg Normal file
View File

@ -0,0 +1,2 @@
[testmemset1\testmemset1.cpp:28]: Using 'memset' on class.
[testmemset1\testmemset1.cpp:34]: Using 'memset' on struct that contains a 'std::string'

View File

@ -0,0 +1,36 @@
class clKalle
{
private:
int i;
public:
clKalle();
};
struct S1
{
char *str;
}
struct S2
{
std::string str;
}
clKalle::clKalle()
{
i = 0;
}
void f()
{
clKalle *kalle = new clKalle;
memset(kalle, 0, sizeof(clKalle));
S1 s1;
memset(&s1, 0, sizeof(S1));
S2 s2;
memset(&s2, 0, sizeof(S2));
}

2
teststdfunc1/err.msg Normal file
View File

@ -0,0 +1,2 @@
[teststdfunc1\teststdfunc1.cpp:4]: The condition can be simplified; use 'isdigit'
[teststdfunc1\teststdfunc1.cpp:9]: The condition can be simplified; use 'isdigit'

View File

@ -0,0 +1,15 @@
void f(char ch)
{
if (ch>='0' && ch<='9')
{
}
if (*p>='0' && *p<='9')
{
}
}