CS.LV_UNUSED.GEN
Unused local variable.
The LV_UNUSED.GEN checker finds local variables that have been declared but never used.
Vulnerability and risk
Unused variables use up stack memory and should be deleted from the function code for that reason. It's also possible that the unused variable points out a logic problem with the code.
Vulnerable code example
Copy
using System;
using System.Security;
using System.Security.Permissions;
namespace TransparencyWarningsDemo
{
public class TransparentMethodsUseSecurityAssertsClass
{
public void test()
{
for(;;){
int i;
break;
}
}
}
}
IKlocwork flags line 7 because variable 'i' is declared but never used.