Looking for a way to configure Coverity such that it will ensure that a declared variable on the stack is initialised prior to its address being passed to another function
For example in the code below x is declared on the stack, but it is not initialised and it is therefore indeterminate. The address of x is then passed to func2. Since the value of x is not defined, the behavior of func2 cannot be certain.
Can Coverity issue a warning for this type of error?
void func1(uint32_t* val)
{
uint32_t x; /*x is not initialised!! */
func2(val, &x);
}
void func2(uint32_t* val, uint32_t* x)
{
uint32_t y;
y = (*x) + (*v);
}
Strange you don't have it, but having UNINIT checker enabled should do the trick.
Check how you execute cov-analyze. You can specify your own checkers configuration there by --dc-config parameter.