Skip to content

TscanCode无法检测出三目运算符(?:)中的uninitvar错误 #90

@zizhanz

Description

@zizhanz

unsigned short TestFunc( unsigned short  InputVal )

{

  unsigned short  RetVal = 0;

  unsigned char   Flag;

 

  if(InputVal > 0) {

    Flag = 1;

  }

 

  RetVal = Flag ? 10 : 0;

 

  return RetVal;

}

 

上面代码中,第10行的Flag在InputVal为0的时候没有初始化。

TscanCode没能检测出这个错误。

 

如果换个写法

  if (Flag) {

    RetVal = 10;

  }

就可以检查出uninitvar错误。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions