VA_UNUSED.INIT

Value is never used after initialization

The VA_UNUSED.INIT checker finds values assigned to local variables in initialization that are never used before the next assignment or the end of the function.

Vulnerability and risk

Unused variable values can indicate that

  • an incorrect variable may be used later in the code
  • there are significant logic errors or other problems with the code

Vulnerable code example

Copy
  int foo(){
    int i = f();
  
    i = g();
    return i;
  }

Klocwork flags line 2, indicating that 'i' is initialized with the value returned from function f(), but the value is never used.

Related checkers