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

1

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

} TST-3./.1 void foo(struct ABC *abc) { int a = abc->a. p = 0. if (!abc). void f(int x) { delete p..otherwise it is redundant to check if abc is null at line 0 Not OK HCLT Confidential Page 3 of 21 ./. } } TST-2. } catch(const exception& err) { throw err.cpp:4]: (error) Possible null pointer dereference: tok\n"./gowda/Desktop/HCL%20New %20Logo.2 void f() { try { foo()." User will be alerted with the following error message "[test. if (x) throw 123..2 variable" User will be alerted with the following error message "[test.cpp:6]: (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 . tok = tok->next(). } TST-2.1 int * p.. 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..jpg" \* MERGEFORMAT ENGF704_1. 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.INCLUDEPICTURE ".3 int foo(const Token *tok) { while (tok).cpp:3]: (error) Possible null pointer (error) Throwing exception in destructor OK (error) Throwing exception in invalid state. } TST-2.0 Test Report x::~x() { throw e. } TST-3.

cpp:4]: (error) Mismatching allocation and deallocation: p\n"..3 User will be alerted with the following error message "[test./gowda/Desktop/HCL%20New %20Logo././. delete [] p. } TST-3.4 (error) Common realloc mistake: 'buf' nulled but not freed upon Not OK Page 4 of 21 . if (!abc)...cpp:4]: (error) Memory leak: p\n". return Q.cpp:4]: (error) Memory leak: p\n". User will be alerted with the following error HCLT Confidential No error found.INCLUDEPICTURE "...){ } } *Q=1.4 No error found. User will be alerted with the following error message "[test. User will be alerted with the following error message "[test. } void foo(struct ABC *abc) { if (abc && abc->a). int *test(int *Z) { int *Q=NULL.. } TST-4.2 (error) Mismatching allocation and deallocation: p OK void f() { int *p = new(std::nothrow) int. } void f() { int *p = new(std::nothrow) int. if (Z) { Q = Z./. } else { try { } catch(.3 (error) Memory leak: p OK static void f() { char *buf = malloc(10).jpg" \* MERGEFORMAT ENGF704_1. Not OK No error found OK (error) Memory leak: p OK void f() { int *p = new(std::nothrow) int.1 User will be alerted with the following error message "[test. TST-4. TST-3. } TST-4.0 Test Report dereference: abc . if (aa) TST-4.cpp:12]: (error) Possible null pointer dereference: Q\n".otherwise it is redundant to check if abc is null at line 4\n".

/. (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]. void f() { char *str = new char[10]. { TST-4./. } static char * f() { char *c = new char[50].9 No Error message./. Failure.. } void foo() char *str = malloc(10).6 User will be alerted with the following error message "[test.. assert(x).jpg" \* MERGEFORMAT ENGF704_1.. free(str). } delete [] x. strcpy(str. p). TST-4.7 No Error message./gowda/Desktop/HCL%20New %20Logo. } message "[test.INCLUDEPICTURE ".0 Test Report .8 User will be alerted with the following error message "[test. free(buf). { TST-4..5 Registration page should have all the required fields. 100)). while (abc) { switch (def) { default: return. else if (buf = realloc(buf.cpp:6]: (error) Common realloc mistake: \'buf\' nulled but not freed upon failure\n". } } delete [] str. } } Not OK TST-4. TST-4. } Not OK HCLT Confidential Page 5 of 21 .cpp:4]: (error) Dereferencing 'str' after it is deallocated / released\n". return (c ? c : NULL).cpp:9]: (error) Memory leak: str\n". if (x == 0 || aa) { return 1. (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).

memset(&(out[0]).INCLUDEPICTURE ". free(str). fprintf(fd.cpp:5]: (error) Deallocating a deallocated pointer: str. strcpy doesn't release it.jpg" \* MERGEFORMAT ENGF704_1. } TST-4. No Error message. } TST-4. \test\).13 void foo() { int *p = malloc(3).cpp:3]: (error) The given size is mismatching\n" User will be alerted with the following error message "[test./gowda/Desktop/HCL%20New %20Logo. Not OK OK HCLT Confidential Page 6 of 21 ./. } void f(std::string foo) { char *out = new char[11]. fclose(fd).0 Test Report void foo() { char *str = malloc(100). } TST-4. strdup(p) ).10 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.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. free(str).15 User will be alerted with the following error message "[test.11 Not OK TST-4.. } void f() { FILE *f = tmpfile(). \wb\).txt\. (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. free(p). 0..14 void x( ) { strcpy(a..././.12 TST-4. 1). } TST-4.

1 void f() TST-6. (performance) Prefer prefix + +/-.1 OK (information) Include file: "iostream" not found. rit= v.\n".push_back(i). TST-5. *s += 10.operators for nonprimitive types. User will be Not OK OK HCLT Confidential Page 7 of 21 . int main(int argc.rend().. ++k./..operators for non-primitive types.rbegin() ) { rit--.2 No Error found. (error) Data is allocated but not initialized: s (error) Memory leak: s (style) Variable OK TST-6.0 Test Report release it. } std::cout << k << std::endl. i < 10. std::vector<int>::reverse_iterator rit. (performance) Prefer prefix + +/-. TST-5. (information) Include file: "vector" not found. std::cout << k << std::endl. int main(int argc./. char *argv[]) { K k(0)./.cpp:7]: (performance) Prefer prefix + +/-.INCLUDEPICTURE ". OK TST-5. char *argv[ ]) { K k(1).cpp:4]: (error) Data is allocated but not initialized: s\n". } void f( ) { char *s = malloc(100). std::cout << k << std::endl.. return 0.3 User will be alerted with the following error message "[test.cpp:7]: (performance) Prefer prefix + +/-. while( rit != v. return 0./gowda/Desktop/HCL%20New %20Logo. (information) Include file: "iostream" not found. } User will be alerted with the following performance message "[test. } return 0. std::cout << k << std::endl. ++i ) v.operators for non-primitive types.2 User will be alerted with the following error message ""[test. } #include <iostream> #include <vector> int main() { std::vector<int> v. for( int i=0.\n". if(k) { k++.jpg" \* MERGEFORMAT ENGF704_1. unsigned int total = 0.operators for nonprimitive types. std::vector<int>::iterator it.\n" #include <iostream> class K { }. } #include <iostream> class K {}..

std::vector<int> ints2.4 No Error message. b(4*a). x = a.end().end()) { ++it. } void foo(const std::set<int> &ints1) { std::set<int> ints2.. i < 4. } return i. std::vector<int>::iterator it = std::find(ints1. 'a' is assigned a value that is never used (error) Uninitialized variable: a OK (error) Uninitialized variable: a No Error message. ++i) { int a. it2).3 alerted with the following error message "[test. } } TST-6.cpp:5]: (error) Uninitialized variable: a\n". ints2.INCLUDEPICTURE ". std::set<int>::iterator it1 = ints1. std::set<int>::iterator it2 = ints1. No Error message. while (it != l2. User will be alerted with the following error message "[test.} void foo() { list<int> l1. list<int>::iterator it = l1.cpp:6]: (error) Uninitialized variable: a\n". ints2.. OK TST-6.1 User will be alerted with the following error message "[test. 22).3 (error) Same iterator is used with both l1 and l2 OK HCLT Confidential Page 8 of 21 . list<int> l2. TST-7.jpg" \* MERGEFORMAT ENGF704_1. if (x==2).begin().cpp:5]: (error) mismatching containers\n".0 Test Report { for (int i = 0. else { char *y = {0}.begin(). User will be alerted with the following error message "[test..insert(it1./. } } static void foo(int x) { int a. } void foo() { std::vector<int> ints1.2 OK TST-7. if (x) i = 22. TST-7.end().begin(). if (x==1)./../.cpp:6]: (error) Same iterator is used with both l1 and (error) mismatching containers OK No Error message. } int foo() { int i./gowda/Desktop/HCL%20New %20Logo. i = 33.

begin(). } } void f() { std::vector<int> ints.begin().5 TST-7.erase(it). next++.begin() + 2. ints. } for (it = foo./. std::cout << (*iter) << std::endl. void foo(std::vector<std::string> &test) { std::set<int> result. } for (it = foo.8 TST-7. } void f(const std::vector<int> &foo) No Error message No Error message OK TST-7.cit != test. iter = ints.end().. it != foo.0 Test Report l2\n". for(std::vector<std::string>::const_iterator cit = test./. iter = ints.begin().begin() + 2.end(). No Error message. ++it) { foo.cpp:3]: (error) Dangerous iterator usage after erase()method. it = next) { next = it.cpp:6]: (error) Invalid iterator: iter\n".9 User will be alerted with the following error message "[test. OK TST-7.INCLUDEPICTURE ".cpp:7]: (error) Dereferenced iterator 'iter' has been erased\n".\n"..jpg" \* MERGEFORMAT ENGF704_1. ++it) { foo.erase(iter)./gowda/Desktop/HCL%20New %20Logo. std::vector<int>::iterator iter. it != foo.end() ++cit) { result. OK No Error message.6 User will be alerted with the following error message "[test. it != foo. (error) Dereferenced iterator 'iter' has been erased OK (error) Dangerous iterator usage after erase()method.7 TST-7.insert(cit->size()). User will be alerted with the following error message "[test.end(). } static void f() { for (iterator it = foo.begin()../.erase(iter). } } void f(std::vector<ints> &ints) { std::vector<int>::iterator iter.erase(it).erase(it). User will be (error) Invalid iterator: iter OK (error) After OK HCLT Confidential Page 9 of 21 . ints..erase(iter). ints. foo.4 TST-7.

cpp:3]: (error) Dangerous usage of c_str()\n" User will be alerted with the following warning message "[test.*it. TST-7. ++it) TST-7. foo. { int *it = &foo[0]. throw errmsg.begin()..INCLUDEPICTURE ".cpp:3]: (style) Redundant checking of STL container element. } } void f() std::string errmsg.11 User will be alerted with the following style message "[test.push_back(123)./.begin(). No Error message.. push_back.remove(needle). the iterator 'it' may be invalid void f() { std::vector<int>::const_iterator it = foo. } { No Error message.12 void f(std::set<int> &ints) { for (std::set<int>::iterator it = ints.end(). errout.begin().str())..int>::iterator it = ints./gowda/Desktop/HCL%20New %20Logo. User will be alerted with the following error message "[test. it != ints. OK TST-7.begin(). } } void f() { if (haystack.13 void f(std::map<int. (Performance) Prefer prefix + +/-.. OK (error) Dangerous usage of c_str() OK TST-7. it != ints. No Error message.end()) { haystack.int> &ints) { for (std::map<int././.cpp:4]: (warning) Missing bounds check for extra iterator increment in loop.cpp:5]: (error) After push_back. ++it) { if (a) { it++. *it = 456.\n". (style) Redundant checking of STL container element.jpg" \* MERGEFORMAT ENGF704_1.foo.c_str().14 (warning) Missing bounds check for extra iterator increment in loop.\n". } alerted with the following error message "[test. the iterator 'it' may be invalid\n".push_back(123).operators for non primitive types.10 No Error message.0 Test Report { std::vector<int>::const_iterator it = foo. Not OK OK HCLT Confidential Page 10 of 21 . } } } TST-7.find(needle) != haystack.end().

c)) { } } TST-7..16 No Error message (error) Division by zero OK OK TST-8.. The result of find is an iterator.0 Test Report { ++it->second./.3 void foo() { std::cout << log(0) << std::endl.. User will be alerted with the following error message "[test.cpp:3]: (warning) Suspicious condition. } } void f() { if (std::find(a.2 void foo() { std::cout << log(-2) << std::endl. No Error message.b. } TST-8. OK void f() { if (std::find(a.0).15 User will be alerted with the following warning message "[test./.INCLUDEPICTURE ".c) != c) { } } void foo() { int a = 0. } TST-7.jpg" \* MERGEFORMAT ENGF704_1./gowda/Desktop/HCL%20New %20Logo.cpp:3]: (error) Division by zero. } TST-8.cpp:5]: (error) Division by zero\n" User will be alerted with the following performance message "[test. double b = 1. The result of find is an iterator.4 (error) Passing value 0 to log() leads to undefined result OK HCLT Confidential Page 11 of 21 .. cout<<b/a.\n".1 (error) Division by zero OK void f() { div_t divresult = div (1./.cpp:3]: (warning) Suspicious condition. } (error) Passing value -2 to log() leads to undefined result OK TST-8.. but it is not properly checked. but it is not properly checked. User will be alerted with the following error message "[test.b.cpp:3]: (error) Passing value -2 to log() leads to undefined result\n" User will be alerted with the following error message "[test.

OK OK void f( int a[ ]) { std::cout << sizeof(a) / sizeof(int) << std::endl. Must be 0 or 236\n" No error message. } TST-8. } TST-8. } void foo() { unsigned int r=32. NULL.0 Test Report (error) Passing value 0 to log() leads to undefined result\n" void foo() { std::string *log(0).jpg" \* MERGEFORMAT ENGF704_1. int v=r/-2./gowda/Desktop/HCL%20New %20Logo..5 No error message User will be alerted with the following error message "[test.cpp:3]: (error) Invalid radix in call to strtol or strtoul. } TST-8. Must be 0 or 236 OK int f(const char *num) { return strtol(num././.. NULL.9 void f( int a[]. The result will be wrong... User will be alerted with the following error message "[test. 1). } TST-8.8 No error message.cpp:2]: (error) Using sizeof for array given as function argument returns the size of pointer.7 (error) Invalid radix in call to strtol or strtoul. User will be alerted with the following error message "[test. 10).6 int f(const char *num) { return strtol(num. (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. int b) { std::cout << sizeof(a) / sizeof(int) << std::endl.10 (error) Using sizeof for array given as function argument returns the size OK HCLT Confidential Page 12 of 21 . } TST-8.cpp:4]: (error) Unsigned Division.INCLUDEPICTURE ".

(performance) Function parameter 'v' should be passed by reference. OK No error message./.\n" User will be alerted with the following performance message "[test. OK (performance) Function parameter 'foo' should be passed by reference..jpg" \* MERGEFORMAT ENGF704_1. int function ( ) { NotAFunction ( 123 ).cpp:4]: of pointer.cpp:1]: (performance) Function parameter 'v' should be passed by reference.INCLUDEPICTURE ".0 Test Report class Foo. (error) fflush() called on input stream "stdin" may result in undefined behaviour OK OK void foo( ) { fflush(stdout). (error) instance of "NotAFunction" object destroyed immediately OK OK HCLT Confidential Page 13 of 21 .13 void foo( ) { fflush(stdin).cpp:2]: (performance) Function parameter 'foo' should be passed by reference../. return 0 . } TST-8./..11 void f(const std::map<std::string. TST-8. User will be alerted with the following error message "[test.\n" No error message./gowda/Desktop/HCL%20New %20Logo..cpp:3]: (error) fflush() called on input stream \"stdin\" may result in undefined behaviour\n" No error message.14 sizeof for array given as function argument returns the size of pointer. } class NotAFunction . void f(const Foo foo) { } TST-8.15 TST-8.12 void f(const std::map<int.int> v) { } TST-8.\n" User will be alerted with the following performance message "[test. User will be alerted with the following error message "[test.16 No error message.int> &v) {} TST-8.

} } { TST-8. OK void f() try { foo().0 Test Report } bool func( int a . } catch( ::std::exception err) { throw err. Not OK void f() try{ foo(). } catch( ::std::exception& err) { throw err.19 (style) Exception should be caught by reference. Not OK void f() { try { foo(). int b ./gowda/Desktop/HCL%20New %20Logo. No error message.18 User will be alerted with the following style message "[test../. OK void foo() { Base * b = (Base *) derived.cpp:4]: (style) C-style pointer casting\n".cpp:6]: (style) Exception should be caught by reference.. } TST-8. (style) Throwing a copy of the caught exception instead of rethrowing the original exception No error message./.. return b == a ./. OK HCLT Confidential Page 14 of 21 .jpg" \* MERGEFORMAT ENGF704_1. int c ) { if ( a > b ) return c == a .21 No error message.17 No error message.\n" No error message.\n" (style) Exception should be caught by reference.20 User will be alerted with the following error message "[test. } (error) instance of \"NotAFunctio n\" object destroyed immediately\n" TST-8. User will be alerted with the following style message "[test. } } TST-8.cpp:6]: (style) Exception should be caught by reference.INCLUDEPICTURE ".. } } { TST-8. } catch(const exception err) { throw err.

(warning) Calling sizeof for 'sizeof'.. return a.cpp:1]: (warning) Found calculation inside sizeof()\n" User will be alerted with the following (information) Please clarify precedence: 'a*b?.27 (style) Variable 'y' is assigned a value that is Not OK HCLT Confidential Page 15 of 21 . assert(a = 2)./gowda/Desktop/HCL%20New %20Logo. assert(a == 2 && b = 1). User will be alerted with the following warning message "[test. } TST-8..jpg" \* MERGEFORMAT ENGF704_1.cpp:2]: (information) Please clarify precedence: 'a*b?..0 Test Report int f(char c) { return 10 * (c == 0) ? 1 : 2. User will be alerted with the following warning message "[test.24 OK void foo() { int i = sizeof sizeof char.25 sizeof(a+b) TST-8.' OK (warning) Assert statement modifies 'a'. int b = 0. TST-8.22 void f() { int a = 0../.23 User will be alerted with the following information message "[test.INCLUDEPICTURE "../. return a. } TST-8./.cpp:4]: (warning)Assert statement modifies 'b'..cpp:4]: (warning)Assert statement modifies 'a'.'\n" User will be alerted with the following warning message "[test.26 (warning) Found calculation inside sizeof() OK void foo() { int y = 1.cpp:3]: (warning) Calling sizeof for 'sizeof'. } TST-8. (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'. } TST-8.\n" User will be alerted with the following warning message "[test. Not OK Not OK void f() { int a = 0.

/gowda/Desktop/HCL%20New %20Logo. return 0. } } warning message "[test. int y) { if (x != 1 || y != 1) a++. OK HCLT Confidential Page 16 of 21 .0 Test Report switch (a) { case 2: y = 2. } 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.30 (warning) Mutual exclusion over || always evaluates to true. TST-9." User will be alerted with the following style message "[test. } No error message TST-8.cpp:7]: (warning) Redundant assignment of \"y\" in switch\n" User will be alerted with the following warning message "[test../.1 TST-9.cpp:4]: (warning) Redundant assignment of \"x\" to itself\n" No error message User will be alerted with the following warning message "[test. void foo() { int x = 1.cpp:2]: (warning) Mutual exclusion over || always evaluates to true.cpp:4]: (style) 'operator=' should return reference to self\n". x = x.28 void f(int x./. } }.INCLUDEPICTURE "./.jpg" \* MERGEFORMAT ENGF704_1.str()).. No Error message. case 3: y = 3. class A { public: A & operator=(const A &).29 OK void f(int x) { if ((x != 1) || (x != 3)) a++. } TST-8. errout.2 No Error message... 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.

. User will be alerted with the following warning message ""[test. A & A::operator=(const A &a) { if (&a ! = this) { } return *this. (style) The class 'Fred' does not have a constructor.str()). return *this. TST-9. A & operator=(const A &a) { free(s). OK TST-9.. } enum ECODES { CODE_1 = 0. class C { FILE *fp. } }./.\n".3 User will be alerted with the following warning message "[test. } class A { public: char *s. class Fred { public: Fred() {} private: ECODES _code. No Error message. CODE_2 = 1 }.4 TST-9. } class Fred { int i.\n".7 User will be alerted with the following style message "[test. }./.cpp:5]: (warning) 'operator=' should check for assignment to self\n".INCLUDEPICTURE "./.. }. OK TST-9.. class A { public: A & operator=(const A &).jpg" \* MERGEFORMAT ENGF704_1.5 (warning) Member variable 'Fred::_code' is not initialised in the constructor OK No Error message. (warning) 'operator=' should check for assignment to self OK No Error message. A & A::operator=(const A &a) { return *this.cpp:1]: (style) The class 'Fred' does not have a constructor. }.cpp:10]: (warning) Member variable 'Fred::_code' is not initialised in the constructor. s = strdup(a. public: C(FILE *fp). }.6 No Error message. OK HCLT Confidential Page 17 of 21 . TST-9.0 Test Report }.s). errout. C::C(FILE *fp) { C::fp = fp./gowda/Desktop/HCL%20New %20Logo.

SIG_IGN).INCLUDEPICTURE ". It is recommended (error) Using 'memset' on struct that contains a 'std::string' OK ./.cpp:3]: (style) Found obsolete function 'bsd_signal'.cpp:3]: (information) Technically the member function 'Fred::foo' can be const.str()). (warning) Suspicious pointer subtraction OK TST-9.\n". OK void f() { bsd_signal(SIGABRT. OK TST-9. void Fred::foobar() {} struct A { void g( struct sockaddr_in6& a).9 User will be alerted with the following error message "[test. } TST-10.11 }. this-x .. } No Error message. memset(&fail./gowda/Desktop/HCL%20New %20Logo.cpp:10]: (error) Using 'memset' on struct that contains a 'std::string'\n"..*this = *this-x . It is recommended that new applications use the 'sigaction' function OK HCLT Confidential Page 18 of 21 . this-x . const std::string & foo() { return . }. private: std::string b.0 Test Report errout.. TST-9. (information) Technically the member function 'Fred::foo' can be const. User will be alerted with the following information message "[test.cpp:2]: (warning) Suspicious pointer subtraction.10 class Fred std::string s. 0. void f() { struct A fail. }./..jpg" \* MERGEFORMAT ENGF704_1. sizeof(struct A)). User will be alerted with the following warning message "[test.1 (style) Found obsolete function 'bsd_signal'. } { TST-9. class Fred { public: static void foobar(). User will be alerted with the following style message "[test./.8 No Error message.

. It is recommended that new appications use the 'getaddrinfo' function (style) Found obsolete function 'usleep'./.jpg" \* MERGEFORMAT ENGF704_1..INCLUDEPICTURE ".0. User will be alerted with the following style message ""[test. } TST-10. sizeof(addr). It is recommended that new applications use the 'nanosleep' or 'setitimer' function./gowda/Desktop/HCL%20New %20Logo./. int f() { int bsd_signal(0).3 Not OK void f() { long addr.cpp:5]: (style) Found obsolete function 'gethostbyaddr'. if(!hp = gethostbyname('127. AF_INET)) { exit(1).cpp:4]: (style) Found obsolete function 'gethostbyname'. Not OK Not OK void f() { struct hostent *hp. addr = inet_addr('127. if(!hp = gethostbyaddr((char *) &addr.1')) { exit(1). 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'.0. User will be alerted with the following style message "[test../.2 No Style message. } TST-10.1'). } } TST-10.0.0..4 void f() { usleep( 1000 ). It is recommended that new applications use the 'getnameinfo' function\n". } } TST-10.0 Test Report that new applications use the 'sigaction' function\n".cpp:3]: (style) Found obsolete function 'usleep'. It is recommended that new applications use the 'getaddrinfo' function\n" User will be alerted with the following style message "[test.5 OK HCLT Confidential Page 19 of 21 . 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'. return bsd_signal.

.7 No Style message (style) Found obsolete function 'gets'.8 static void f( ) { int data[2]. User will be alerted with the following style message "[test. } TST-10.2 TST-11.cpp:5]: (error) Array 'str[16]' index 16 out of bounds\n" User will be alerted with the (style) Found obsolete function 'rindex'.jpg" \* MERGEFORMAT ENGF704_1.0 Test Report void f() { const char var[7] = 'rindex'. No Style message User will be alerted with the following style message "[test.cpp:4]: (error) Array 'data[2]' index 4 out of bounds\n" User will be alerted with the following error message "[test. 0)).INCLUDEPICTURE ". } (error) Array 'data[2]' index 4 out of bounds OK TST-11.6 applications use the 'nanosleep' or 'setitimer' function\n". } TST-10. User will be alerted with the following error message "[test. } TST-10. It is recommended to use the function ‘fgets' instead OK OK void f() { char *x = gets(). It is recommended to use the function 'strrchr' instead\n". } void f( ) { No Error message Not OK TST-11./.cpp:3]: (style) Found obsolete function 'gets'.. print(rindex(var. data[ sizeof(data[0]) ] = 0. It is recommended to use the function 'fgets' instead\n". str[15] = 0..3 (style) Variable 'val' is assigned Not OK HCLT Confidential Page 20 of 21 ././gowda/Desktop/HCL%20New %20Logo.. str[16] = 0./. It is recommended to use the function 'strrchr' instead OK void f() { int rindex( 0 ).cpp:4]: (style) Found obsolete function 'rindex'.1 void f() { char str[0x10].

argv[0]). char* argv[]) { char prog[10]. int i.. } 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.0 Test Report int val[50]..INCLUDEPICTURE ".cpp:6]: (error) Buffer access out-ofbounds: val\n" User will be alerted with the following style message "[test. i < 100. for (i = 0. i++) sum += val[i].jpg" \* MERGEFORMAT ENGF704_1./. sum=0. } following style message "[test.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 ./..cpp:4]: (error) Buffer overrun possible for long cmd-line args\n" main(int argc../gowda/Desktop/HCL%20New %20Logo. strcpy(prog./.