INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.
0 Test Report
Test Report
Stage of test Customer Name Drawing / Specification Number Vendor Name1
Final
Date Product / System Name Project Code / Name
30/08/2011 Cppcheck 2
HCLT
Vendor P.O. reference Tested By
Test Cycle Number Participants
1 User-3
Manual
Reference of tools used
Calibration details
Visual C++
2008 Express edition
Parameters tested
Referenc e
Expected results
Actual results
OK / Not OK
void func1(int **res) { int num = 2; *res = # }
TST-1.1
void func1(int arr[2]) { int num=2; arr[0]=# }
TST-1.2
User will be alerted with the following error message "[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter." User will be alerted with the following error message "[test.cpp:3]: (error) Assigning address of local auto-variable to a function parameter."
(error) Assigning address of local auto-variable to a function parameter.
OK
No error found.
Not OK
Applicable for subcontracted items
HCLT Confidential Page 1 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
void func1(int arr[2]) { int num=2; arr[0]=# } char *foo() { char str[100] = {0}; return str; }
TST-1.3 No error found. TST-1.4 user will be alerted with following error message "[test.cpp:4]: (error) Returning pointer to local array variable" No error found. TST-1.6 User will be alerted with the following error message "[test.cpp:3]: (error) Return of the address of an auto-variable." User will be alerted with the following error message "[test.cpp:4]: (error) Returning reference to auto variable" User will be alerted with the following error message "[test.cpp:4]: (error) Returning reference to auto variable" User will be alerted with the following error message "[test.cpp:4]: (error) Returning pointer to auto
(style) Variable 'num' is assigned a value that is never used (error) Returning pointer to local array variable
OK
OK
std::string foo() { char str[100] = {0}; return str; } int func1() { int num=2; return # }
TST-1.5
(style) Variable 'num' is assigned a value that is never used (style) Variable 'num' is assigned a value that is never used
OK
Not OK
string &foo() { string s; return s; }
TST-1.7
(error) Returning reference to auto variable
OK
std::vector<int> &foo() { std::vector<int> v; return v; }
TST-1.8
(error) Returning reference to auto variable
OK
const char *foo() { std::string s; return s.c_str(); }
TST-1.9
(error) Returning pointer to auto variable
OK
HCLT Confidential
Page 2 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
x::~x() { throw e; }
TST-2.1
int * p; void f(int x) { delete p; if (x) throw 123; p = 0; }
TST-2.2
void f() { try { foo(); } catch(const exception& err) { throw err; } }
TST-2.3
int foo(const Token *tok) { while (tok); tok = tok->next(); }
TST-3.1
void foo(struct ABC *abc) { int a = abc->a; if (!abc); }
TST-3.2
variable" User will be alerted with the following error message "[test.cpp:3]: (error) Throwing exception in destructor" User will be alerted with the following error message "[test.cpp:6]: (error) Throwing exception in invalid state, p points at deallocated memory" User will be alerted with the following error message "[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception." User will be alerted with the following error message "[test.cpp:4]: (error) Possible null pointer dereference: tok\n". User will be alerted with the following error message "[test.cpp:3]: (error) Possible null pointer
(error) Throwing exception in destructor
OK
(error) Throwing exception in invalid state, p points at deallocated memory
OK
(style) Throwing a copy of the caught exception instead of rethrowing the original exception
OK
(error) Possible null pointer dereference: tok
OK
(error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 0
Not OK
HCLT Confidential
Page 3 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
dereference: abc - otherwise it is redundant to check if abc is null at line 4\n". int *test(int *Z) { int *Q=NULL; if (Z) { Q = Z; } else { try { } catch(...){ } } *Q=1; return Q; } void foo(struct ABC *abc) { if (abc && abc->a); if (!abc); } void f() { int *p = new(std::nothrow) int; } TST-3.3 User will be alerted with the following error message "[test.cpp:12]: (error) Possible null pointer dereference: Q\n". TST-3.4 No error found. TST-4.1 User will be alerted with the following error message "[test.cpp:4]: (error) Memory leak: p\n". User will be alerted with the following error message "[test.cpp:4]: (error) Mismatching allocation and deallocation: p\n". User will be alerted with the following error message "[test.cpp:4]: (error) Memory leak: p\n". User will be alerted with the following error
HCLT Confidential
No error found.
Not OK
No error found
OK
(error) Memory leak: p
OK
void f() { int *p = new(std::nothrow) int; delete [] p; }
TST-4.2
(error) Mismatching allocation and deallocation: p
OK
void f() { int *p = new(std::nothrow) int; }
TST-4.3
(error) Memory leak: p
OK
static void f() { char *buf = malloc(10); if (aa)
TST-4.4
(error) Common realloc mistake: 'buf' nulled but not freed upon
Not OK
Page 4 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
; else if (buf = realloc(buf, 100)); free(buf); }
message "[test.cpp:6]: (error) Common realloc mistake: \'buf\' nulled but not freed upon failure\n". TST-4.5 Registration page should have all the required fields. TST-4.6 User will be alerted with the following error message "[test.cpp:9]: (error) Memory leak: str\n".
Failure. (error) Mismatching allocation and deallocation: buf (error) Mismatching allocation and deallocation: x (error) Mismatching allocation and deallocation: str (error) Memory leak: str Not OK
void foo() { int *x = new int[10]; if (x == 0 || aa) { return 1; } delete [] x; void f() { char *str = new char[10]; while (abc) { switch (def) { default: return; } } delete [] str; } static char * f() { char *c = new char[50]; return (c ? c : NULL); } void foo() char *str = malloc(10); free(str); strcpy(str, p); }
Not OK
TST-4.7 No Error message. { TST-4.8 User will be alerted with the following error message "[test.cpp:4]: (error) Dereferencing 'str' after it is deallocated / released\n". { TST-4.9 No Error message.
(style) Variable 'c' is assigned a value that is never used (error) Mismatching allocation and deallocation: str (error) Dereferencing 'str' after it is deallocated / r (error) Uninitialized variable: str (style) Variable 'str' is allocated memory that is never used
OK
Not OK
void foo(int x) char *str = malloc(10); free(str); assert(x); }
Not OK
HCLT Confidential
Page 5 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
void foo() { char *str = malloc(100); free(str); free(str); }
TST-4.10
User will be alerted with the following error message "[test.cpp:5]: (error) Deallocating a deallocated pointer: str. No Error message.
(error) Mismatching allocation and deallocation: str (error) Mismatching allocation and deallocation: str (error) Deallocating a deallocated pointer: str (error) Resource leak: fd
Not OK
void foo() { FILE *fd = fopen(\test.txt\, \wb\); fprintf(fd, \test\); fclose(fd); } void f(std::string foo) { char *out = new char[11]; memset(&(out[0]), 0, 1); } void f() { FILE *f = tmpfile(); }
TST-4.11
Not OK
TST-4.12
TST-4.13
void foo() { int *p = malloc(3); free(p); }
TST-4.14
void x( ) { strcpy(a, strdup(p) ); }
TST-4.15
User will be alerted with the following error message "[test.cpp:5]: (error) Memory leak: out\n" User will be alerted with the following error message "[test.cpp:4]: (error) Resource leak: f\n" User will be alerted with the following error message "[test.cpp:3]: (error) The given size is mismatching\n" User will be alerted with the following error message "[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't
(error) Memory leak: out
OK
(error) Resource leak: f
OK
(error) The given size 3 is mismatching (error) Mismatching allocation and deallocation: p (error) Allocation with strdup, strcpy doesn't release it.
Not OK
OK
HCLT Confidential
Page 6 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
release it.\n" #include <iostream> class K { }; int main(int argc, char *argv[ ]) { K k(1); std::cout << k << std::endl; if(k) { k++; } std::cout << k << std::endl; return 0; } #include <iostream> class K {}; int main(int argc, char *argv[]) { K k(0); std::cout << k << std::endl; ++k; std::cout << k << std::endl; return 0; } #include <iostream> #include <vector> int main() { std::vector<int> v; std::vector<int>::iterator it; for( int i=0; i < 10; ++i ) v.push_back(i); unsigned int total = 0; std::vector<int>::reverse_iterator rit; rit= v.rend(); while( rit != v.rbegin() ) { rit--; } return 0; } void f( ) { char *s = malloc(100); *s += 10; } User will be alerted with the following performance message "[test.cpp:7]: (performance) Prefer prefix + +/-- operators for non-primitive types.\n". (performance) Prefer prefix + +/-- operators for nonprimitive types. OK
TST-5.1
OK (information) Include file: "iostream" not found.
TST-5.2
No Error found.
TST-5.3
User will be alerted with the following error message "[test.cpp:7]: (performance) Prefer prefix + +/-- operators for non-primitive types.\n".
(performance) Prefer prefix + +/-- operators for nonprimitive types. (information) Include file: "vector" not found. (information) Include file: "iostream" not found. (error) Data is allocated but not initialized: s (error) Memory leak: s (style) Variable
OK
TST-6.1
void f()
TST-6.2
User will be alerted with the following error message ""[test.cpp:4]: (error) Data is allocated but not initialized: s\n". User will be
Not OK
OK
HCLT Confidential
Page 7 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
{ for (int i = 0; i < 4; ++i) { int a; b(4*a); } }
static void foo(int x) { int a; if (x==1); if (x==2); x = a; } int foo() { int i; if (x) i = 22; else { char *y = {0}; i = 33; } return i; } void foo() { std::vector<int> ints1; std::vector<int> ints2; std::vector<int>::iterator it = std::find(ints1.begin(), ints2.end(), 22); } void foo(const std::set<int> &ints1) { std::set<int> ints2; std::set<int>::iterator it1 = ints1.begin(); std::set<int>::iterator it2 = ints1.end(); ints2.insert(it1, it2);} void foo() { list<int> l1; list<int> l2; list<int>::iterator it = l1.begin(); while (it != l2.end()) { ++it; } }
TST-6.3
alerted with the following error message "[test.cpp:5]: (error) Uninitialized variable: a\n". User will be alerted with the following error message "[test.cpp:6]: (error) Uninitialized variable: a\n".
'a' is assigned a value that is never used (error) Uninitialized variable: a OK (error) Uninitialized variable: a
No Error message.
OK
TST-6.4
No Error message.
TST-7.1
User will be alerted with the following error message "[test.cpp:5]: (error) mismatching containers\n". No Error message. User will be alerted with the following error message "[test.cpp:6]: (error) Same iterator is used with both l1 and
(error) mismatching containers
OK
No Error message. TST-7.2
OK
TST-7.3
(error) Same iterator is used with both l1 and l2
OK
HCLT Confidential
Page 8 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
l2\n". void foo(std::vector<std::string> &test) { std::set<int> result; for(std::vector<std::string>::const_iterator cit = test.begin();cit != test.end() ++cit) { result.insert(cit->size()); } } void f() { std::vector<int> ints; std::vector<int>::iterator iter; iter = ints.begin() + 2; ints.erase(iter); std::cout << (*iter) << std::endl; } for (it = foo.begin(); it != foo.end(); ++it) { foo.erase(it); } for (it = foo.begin(); it != foo.end(); ++it) { foo.erase(it); } static void f() { for (iterator it = foo.begin(); it != foo.end(); it = next) { next = it; next++; foo.erase(it); } } void f(std::vector<ints> &ints) { std::vector<int>::iterator iter; iter = ints.begin() + 2; ints.erase(iter); ints.erase(iter); } void f(const std::vector<int> &foo) No Error message No Error message OK
TST-7.4
TST-7.5
TST-7.6
User will be alerted with the following error message "[test.cpp:7]: (error) Dereferenced iterator 'iter' has been erased\n". User will be alerted with the following error message "[test.cpp:3]: (error) Dangerous iterator usage after erase()method.\n".
(error) Dereferenced iterator 'iter' has been erased
OK
(error) Dangerous iterator usage after erase()method.
OK
No Error message. No Error message.
OK
TST-7.7
TST-7.8
TST-7.9
User will be alerted with the following error message "[test.cpp:6]: (error) Invalid iterator: iter\n". User will be
(error) Invalid iterator: iter
OK
(error) After
OK
HCLT Confidential
Page 9 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
{ std::vector<int>::const_iterator it = foo.begin();foo.push_back(123);*it; }
alerted with the following error message "[test.cpp:5]: (error) After push_back, the iterator 'it' may be invalid\n".
push_back, the iterator 'it' may be invalid
void f() { std::vector<int>::const_iterator it = foo.begin(); foo.push_back(123); { int *it = &foo[0]; *it = 456; } } void f() { if (haystack.find(needle) != haystack.end()) { haystack.remove(needle); } } void f() std::string errmsg; throw errmsg.c_str(); } {
No Error message. TST-7.10 No Error message.
OK
TST-7.11
User will be alerted with the following style message "[test.cpp:3]: (style) Redundant checking of STL container element.\n". User will be alerted with the following error message "[test.cpp:3]: (error) Dangerous usage of c_str()\n" User will be alerted with the following warning message "[test.cpp:4]: (warning) Missing bounds check for extra iterator increment in loop.\n", errout.str()); No Error message.
(style) Redundant checking of STL container element.
OK
(error) Dangerous usage of c_str()
OK
TST-7.12
void f(std::set<int> &ints) { for (std::set<int>::iterator it = ints.begin(); it != ints.end(); ++it) { if (a) { it++; } } } TST-7.13
void f(std::map<int,int> &ints) { for (std::map<int,int>::iterator it = ints.begin(); it != ints.end(); ++it)
TST-7.14
(warning) Missing bounds check for extra iterator increment in loop. (Performance) Prefer prefix + +/-- operators for non primitive types. No Error message.
Not OK
OK
HCLT Confidential
Page 10 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
{ ++it->second; } } void f() { if (std::find(a,b,c)) { } } TST-7.15 User will be alerted with the following warning message "[test.cpp:3]: (warning) Suspicious condition. The result of find is an iterator, but it is not properly checked.\n". No Error message. User will be alerted with the following error message "[test.cpp:5]: (error) Division by zero\n" User will be alerted with the following performance message "[test.cpp:3]: (error) Division by zero. User will be alerted with the following error message "[test.cpp:3]: (error) Passing value -2 to log() leads to undefined result\n" User will be alerted with the following error message "[test.cpp:3]: (warning) Suspicious condition. The result of find is an iterator, but it is not properly checked. OK
void f() { if (std::find(a,b,c) != c) { } } void foo() { int a = 0; double b = 1.; cout<<b/a; }
TST-7.16
No Error message (error) Division by zero
OK
OK
TST-8.1
(error) Division by zero
OK
void f() { div_t divresult = div (1,0); }
TST-8.2
void foo() { std::cout << log(-2) << std::endl; }
(error) Passing value -2 to log() leads to undefined result
OK
TST-8.3
void foo() { std::cout << log(0) << std::endl; }
TST-8.4
(error) Passing value 0 to log() leads to undefined result
OK
HCLT Confidential
Page 11 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
(error) Passing value 0 to log() leads to undefined result\n" void foo() { std::string *log(0); } void foo() { unsigned int r=32; int v=r/-2; } TST-8.5 No error message User will be alerted with the following error message "[test.cpp:4]: (error) Unsigned Division. The result will be wrong. User will be alerted with the following error message "[test.cpp:3]: (error) Invalid radix in call to strtol or strtoul. Must be 0 or 236\n" No error message. User will be alerted with the following error message "[test.cpp:2]: (error) Using sizeof for array given as function argument returns the size of pointer.\n" User will be alerted with the following error message "[test.cpp:2]: (error) Using No error message No error message OK
Not OK
TST-8.6
int f(const char *num) { return strtol(num, NULL, 1); }
TST-8.7
(error) Invalid radix in call to strtol or strtoul. Must be 0 or 236
OK
int f(const char *num) { return strtol(num, NULL, 10); }
TST-8.8
No error message. (error) Using sizeof for array given as function argument returns the size of pointer.
OK
OK
void f( int a[ ]) { std::cout << sizeof(a) / sizeof(int) << std::endl; }
TST-8.9
void f( int a[], int b) { std::cout << sizeof(a) / sizeof(int) << std::endl; }
TST-8.10
(error) Using sizeof for array given as function argument returns the size
OK
HCLT Confidential
Page 12 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
class Foo; void f(const Foo foo) { }
TST-8.11
void f(const std::map<std::string,int> v) { }
TST-8.12
void f(const std::map<int,int> &v) {}
TST-8.13
void foo( ) { fflush(stdin); }
TST-8.14
sizeof for array given as function argument returns the size of pointer.\n" User will be alerted with the following performance message "[test.cpp:2]: (performance) Function parameter 'foo' should be passed by reference.\n" User will be alerted with the following performance message "[test.cpp:1]: (performance) Function parameter 'v' should be passed by reference.\n" No error message. User will be alerted with the following error message "[test.cpp:3]: (error) fflush() called on input stream \"stdin\" may result in undefined behaviour\n" No error message. User will be alerted with the following error message "[test.cpp:4]:
of pointer.
OK (performance) Function parameter 'foo' should be passed by reference.
(performance) Function parameter 'v' should be passed by reference.
OK
No error message. (error) fflush() called on input stream "stdin" may result in undefined behaviour
OK OK
void foo( ) { fflush(stdout); } class NotAFunction ; int function ( ) { NotAFunction ( 123 ); return 0 ;
TST-8.15 TST-8.16
No error message. (error) instance of "NotAFunction" object destroyed immediately
OK
OK
HCLT Confidential
Page 13 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
} bool func( int a , int b , int c ) { if ( a > b ) return c == a ; return b == a ; }
(error) instance of \"NotAFunctio n\" object destroyed immediately\n" TST-8.17 No error message. No error message. OK
void foo() { Base * b = (Base *) derived; }
TST-8.18
User will be alerted with the following style message "[test.cpp:4]: (style) C-style pointer casting\n". User will be alerted with the following style message "[test.cpp:6]: (style) Exception should be caught by reference.\n"
No error message.
Not OK
void f() { try { foo(); } catch( ::std::exception err) { throw err; } }
TST-8.19
(style) Exception should be caught by reference.
OK
void f() try { foo(); } catch(const exception err) { throw err; } }
{ TST-8.20
User will be alerted with the following error message "[test.cpp:6]: (style) Exception should be caught by reference.\n"
(style) Exception should be caught by reference. (style) Throwing a copy of the caught exception instead of rethrowing the original exception No error message.
Not OK
void f() try{ foo(); } catch( ::std::exception& err) { throw err; } }
{ TST-8.21 No error message.
OK
HCLT Confidential
Page 14 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
int f(char c) { return 10 * (c == 0) ? 1 : 2; }
TST-8.22
void f() { int a = 0; assert(a = 2); return a; }
TST-8.23
User will be alerted with the following information message "[test.cpp:2]: (information) Please clarify precedence: 'a*b?..'\n" User will be alerted with the following warning message "[test.cpp:4]: (warning)Assert statement modifies 'a'. User will be alerted with the following warning message "[test.cpp:4]: (warning)Assert statement modifies 'b'. User will be alerted with the following warning message "[test.cpp:3]: (warning) Calling sizeof for 'sizeof'.\n" User will be alerted with the following warning message "[test.cpp:1]: (warning) Found calculation inside sizeof()\n" User will be alerted with the following
(information) Please clarify precedence: 'a*b?..'
OK
(warning) Assert statement modifies 'a'. (style) Variable 'a' is assigned a value that is never used (style) Variable 'a' is assigned a value that is never used (style) Variable 'b' is assigned a value that is never used (warning) Assert statement modifies 'b'. (warning) Calling sizeof for 'sizeof'.
Not OK
Not OK
void f() { int a = 0; int b = 0; assert(a == 2 && b = 1); return a; }
TST-8.24
OK
void foo() { int i = sizeof sizeof char; }
TST-8.25
sizeof(a+b)
TST-8.26
(warning) Found calculation inside sizeof()
OK
void foo() { int y = 1;
TST-8.27
(style) Variable 'y' is assigned a value that is
Not OK
HCLT Confidential
Page 15 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
switch (a) { case 2: y = 2; case 3: y = 3; } }
warning message "[test.cpp:7]: (warning) Redundant assignment of \"y\" in switch\n" User will be alerted with the following warning message "[test.cpp:4]: (warning) Redundant assignment of \"x\" to itself\n" No error message User will be alerted with the following warning message "[test.cpp:2]: (warning) Mutual exclusion over || always evaluates to true." User will be alerted with the following style message "[test.cpp:4]: (style) 'operator=' should return reference to self\n", errout.str()); No Error message.
void foo() { int x = 1; x = x; return 0; }
never used (information) The scope of the variable y can be reduced (warning) Redundant assignment of "y" in switch (style) Variable 'x' is assigned a value that is never used
Not OK
TST-8.28
void f(int x, int y) { if (x != 1 || y != 1) a++; }
No error message TST-8.29
OK
void f(int x) { if ((x != 1) || (x != 3)) a++; }
TST-8.30
(warning) Mutual exclusion over || always evaluates to true. Did you intend to use && instead? (style) 'operator=' should return reference to self
OK
OK
class A { public: A & operator=(const A &a) { return a; } }; class A { public: A & operator=(const A &);
TST-9.1
TST-9.2
No Error message.
OK
HCLT Confidential
Page 16 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
}; A & A::operator=(const A &a) { return *this; } class A { public: char *s; A & operator=(const A &a) { free(s); s = strdup(a.s); return *this; } }; class A { public: A & operator=(const A &); }; A & A::operator=(const A &a) { if (&a ! = this) { } return *this; } enum ECODES { CODE_1 = 0, CODE_2 = 1 }; class Fred { public: Fred() {} private: ECODES _code; }; class C { FILE *fp; public: C(FILE *fp); }; C::C(FILE *fp) { C::fp = fp; } class Fred { int i; };
TST-9.3
User will be alerted with the following warning message "[test.cpp:5]: (warning) 'operator=' should check for assignment to self\n". No Error message. User will be alerted with the following warning message ""[test.cpp:10]: (warning) Member variable 'Fred::_code' is not initialised in the constructor.\n".
(warning) 'operator=' should check for assignment to self
OK
No Error message.
OK
TST-9.4
TST-9.5
(warning) Member variable 'Fred::_code' is not initialised in the constructor
OK
No Error message. TST-9.6 No Error message.
OK
TST-9.7
User will be alerted with the following style message "[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n",
(style) The class 'Fred' does not have a constructor. errout.str());
OK
HCLT Confidential
Page 17 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
errout.str()); class Fred { public: static void foobar(); }; void Fred::foobar() {} struct A { void g( struct sockaddr_in6& a); private: std::string b; }; void f() { struct A fail; memset(&fail, 0, sizeof(struct A)); } No Error message. TST-9.8 No Error message. OK
TST-9.9
User will be alerted with the following error message "[test.cpp:10]: (error) Using 'memset' on struct that contains a 'std::string'\n". User will be alerted with the following warning message "[test.cpp:2]: (warning) Suspicious pointer subtraction. User will be alerted with the following information message "[test.cpp:3]: (information) Technically the member function 'Fred::foo' can be const.\n". User will be alerted with the following style message "[test.cpp:3]: (style) Found obsolete function 'bsd_signal'. It is recommended
(error) Using 'memset' on struct that contains a 'std::string'
OK
;*this = *this-x ; this-x ; this-x ;
(warning) Suspicious pointer subtraction
OK
TST-9.10
class Fred std::string s; const std::string & foo() { return ; }
{ TST-9.11 };
(information) Technically the member function 'Fred::foo' can be const.
OK
void f() { bsd_signal(SIGABRT, SIG_IGN); }
TST-10.1
(style) Found obsolete function 'bsd_signal'. It is recommended that new applications use the 'sigaction' function
OK
HCLT Confidential
Page 18 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
that new applications use the 'sigaction' function\n". int f() { int bsd_signal(0); return bsd_signal; } TST-10.2 No Style message. User will be alerted with the following style message ""[test.cpp:4]: (style) Found obsolete function 'gethostbyname'. It is recommended that new applications use the 'getnameinfo' function\n". User will be alerted with the following style message "[test.cpp:5]: (style) Found obsolete function 'gethostbyaddr'. It is recommended that new applications use the 'getaddrinfo' function\n" User will be alerted with the following style message "[test.cpp:3]: (style) Found obsolete function 'usleep'. It is recommended that new (style) Variable 'bsd_signal' is assigned a value that is never used (style) Variable 'hp' is assigned a value that is never used (style) Found obsolete function 'gethostbyname'. It is recommended that new applications use the 'getnameinfo' function (style) Variable 'addr' is assigned a value that is never used (style) Found obsolete function 'gethostbyaddr'. It is recommended that new appications use the 'getaddrinfo' function (style) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function. Not OK
Not OK
void f() { struct hostent *hp; if(!hp = gethostbyname('127.0.0.1')) { exit(1); } }
TST-10.3
Not OK
void f() { long addr; addr = inet_addr('127.0.0.1'); if(!hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) { exit(1); } }
TST-10.4
void f() { usleep( 1000 ); }
TST-10.5
OK
HCLT Confidential
Page 19 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
void f() { const char var[7] = 'rindex'; print(rindex(var, 0)); }
TST-10.6
applications use the 'nanosleep' or 'setitimer' function\n". User will be alerted with the following style message "[test.cpp:4]: (style) Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead\n". No Style message User will be alerted with the following style message "[test.cpp:3]: (style) Found obsolete function 'gets'. It is recommended to use the function 'fgets' instead\n". User will be alerted with the following error message "[test.cpp:4]: (error) Array 'data[2]' index 4 out of bounds\n" User will be alerted with the following error message "[test.cpp:5]: (error) Array 'str[16]' index 16 out of bounds\n" User will be alerted with the
(style) Found obsolete function 'rindex'. It is recommended to use the function 'strrchr' instead
OK
void f() { int rindex( 0 ); }
TST-10.7
No Style message (style) Found obsolete function 'gets'. It is recommended to use the function fgets' instead
OK
OK
void f() { char *x = gets(); }
TST-10.8
static void f( ) { int data[2]; data[ sizeof(data[0]) ] = 0; }
(error) Array 'data[2]' index 4 out of bounds
OK
TST-11.1
void f() { char str[0x10]; str[15] = 0; str[16] = 0; } void f( ) {
No Error message
Not OK
TST-11.2
TST-11.3
(style) Variable 'val' is assigned
Not OK
HCLT Confidential
Page 20 of 21
INCLUDEPICTURE "../../../../gowda/Desktop/HCL%20New %20Logo.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report
int val[50]; int i, sum=0; for (i = 0; i < 100; i++) sum += val[i]; }
following style message "[test.cpp:6]: (error) Buffer access out-ofbounds: val\n" User will be alerted with the following style message "[test.cpp:4]: (error) Buffer overrun possible for long cmd-line args\n"
main(int argc, char* argv[]) { char prog[10]; strcpy(prog, argv[0]); }
a value that is never used (error) Buffer access out-ofbounds: val (error) Uninitialized variable: val (error) Buffer overrun possible for long cmdline args
OK
TST-11.4
Re-inspection by
Re-inspection date
Remarks
Test Result:
Accepted
Rejected
Recommendations for additional tests:
Any other comments:
HCLT Confidential
Page 21 of 21