Working with source defect files

While the exact format of your defect source can vary, the data must be valid and it must contain at least the following four elements per defect:

Element Description
Defect code A string representing the high-level category of the defect. In the example below, the defect code is represented by the element <ErrorId>.
File name

The absolute path and file name or a relative path and file name of the source file that contains the current defect. If you specify the --working-directory argument to

kwdefectimport

, the file name is considered a relative link (relative to the value specified in the argument). If you don't specify a working directory, the file name must be an absolute path.

In the example below, the file name is represented by the F attribute.

Line number

The line number (in the source file) that contains the defect.

In the example below, the file name is represented by the L attribute.

Message Optional. The message explaining the defect. The message is displayed within Klocwork and provides context to the user.

The following listing shows a typical defect source file.

<ErrorId Id="ERR_TYP_TIMER_NOT_ACTIVE" NumberOfEntries="4">
  <Msg F="czagenmx.sdl" L="2786" S="C">timer t_wf_czg not activated in any path</Msg>
  <Msg F="czahanmx.sdl" L="5051" S="C">timer t_wf_czg_sup_ack not activated in any path</Msg>
  <Msg F="czahanmx.sdl" L="5074" S="C">timer t_wf_czg_sup_ack not activated in any path</Msg>
  <Msg F="czahanmx.sdl" L="5092" S="C">timer t_wf_czg_sup_ack not activated in any path</Msg>
</ErrorId>  

The sample also contains the S attribute which represents the severity level of each defect. Since the severity level of each defect is defined in the taxonomy, this attribute can be ignored by the parser.