Skip to content

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

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错误。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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