uninitialized variables: Added some comments
This commit is contained in:
parent
3c238882a2
commit
c8775344d6
|
@ -101,6 +101,8 @@ private:
|
||||||
/** allocating pointer. For example : p = malloc(10); */
|
/** allocating pointer. For example : p = malloc(10); */
|
||||||
static void alloc_pointer(std::list<ExecutionPath *> &checks, unsigned int varid)
|
static void alloc_pointer(std::list<ExecutionPath *> &checks, unsigned int varid)
|
||||||
{
|
{
|
||||||
|
// loop through the checks and perform a allocation if the
|
||||||
|
// variable id matches
|
||||||
std::list<ExecutionPath *>::const_iterator it;
|
std::list<ExecutionPath *>::const_iterator it;
|
||||||
for (it = checks.begin(); it != checks.end(); ++it)
|
for (it = checks.begin(); it != checks.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -117,6 +119,8 @@ private:
|
||||||
if (!varid)
|
if (!varid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// loop through the checks and perform a initialization if the
|
||||||
|
// variable id matches
|
||||||
std::list<ExecutionPath *>::iterator it = checks.begin();
|
std::list<ExecutionPath *>::iterator it = checks.begin();
|
||||||
while (it != checks.end())
|
while (it != checks.end())
|
||||||
{
|
{
|
||||||
|
@ -146,12 +150,15 @@ private:
|
||||||
if (!varid)
|
if (!varid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// loop through the checks and perform a deallocation if the
|
||||||
|
// variable id matches
|
||||||
std::list<ExecutionPath *>::const_iterator it;
|
std::list<ExecutionPath *>::const_iterator it;
|
||||||
for (it = checks.begin(); it != checks.end(); ++it)
|
for (it = checks.begin(); it != checks.end(); ++it)
|
||||||
{
|
{
|
||||||
UninitVar *c = dynamic_cast<UninitVar *>(*it);
|
UninitVar *c = dynamic_cast<UninitVar *>(*it);
|
||||||
if (c && c->varId == varid)
|
if (c && c->varId == varid)
|
||||||
{
|
{
|
||||||
|
// unallocated pointer variable => error
|
||||||
if (c->pointer && !c->alloc)
|
if (c->pointer && !c->alloc)
|
||||||
{
|
{
|
||||||
CheckUninitVar *checkUninitVar = dynamic_cast<CheckUninitVar *>(c->owner);
|
CheckUninitVar *checkUninitVar = dynamic_cast<CheckUninitVar *>(c->owner);
|
||||||
|
@ -175,10 +182,12 @@ private:
|
||||||
*/
|
*/
|
||||||
static void pointer_assignment(std::list<ExecutionPath *> &checks, const Token *tok1, const Token *tok2)
|
static void pointer_assignment(std::list<ExecutionPath *> &checks, const Token *tok1, const Token *tok2)
|
||||||
{
|
{
|
||||||
|
// Variable id for "left hand side" variable
|
||||||
const unsigned int varid1(tok1->varId());
|
const unsigned int varid1(tok1->varId());
|
||||||
if (varid1 == 0)
|
if (varid1 == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Variable id for "right hand side" variable
|
||||||
const unsigned int varid2(tok2->varId());
|
const unsigned int varid2(tok2->varId());
|
||||||
if (varid2 == 0)
|
if (varid2 == 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue