The result of a checker

Coverity Documentation

Version
latest

If your for loop is the main loop of a checker, then its result-expression must have a specific form; namely, it must be an expression that contains a record named events.

In its turn, events must define two properties: one named description and the other named location.

Both these properties contribute to the issue report: the description specifies a string to display, and the location specifies the code location where the issue was found.

For example, the following code shows the result-expression for a checker named UNINIT_VAR:

CXM code follows
    {
        events = [
            {
                description = "Variable "
                              + decl.variable
                              + " is declared but not initialized.";
                location = code.location; 
            }
        ]
    };

A fine point: In this example, code is the loop variable. When you traverse the globalset, the loop variable has a .location property that contains the source-line number where the loop criterion was met.