Next: splint
Up: TUTTI Reference
Previous: Tutorial
  Contents
  Index
Subsections
qac
This chapters describes how QAC is supported by TUTTI. As QAC is a
static analysis tool, it is supported with a compiler wrapper and a result
scanner like splint (which is also a static analysis tool). QAC allows
to analyze the source code without execution of this code. Hence it can
be applied in the early stage of development.
qac_compiler
qac_compiler is a wrapper for QAC static analysis tool. It as the same
interface as the gnu compiler collection (gcc). The compiler wrapper
will compile the source code using the parameters specified at command
line. It will also invoke QAC to analyze the source code. This results
in annotated source code files with extension .qac. The annotated source
file contain warnings that QAC has issued.
Language subsetting
There are two warning subsets that can be applied by qac_compiler. These
language subsets represent the two different programming standard
(i.e. the ABSOLUTE programming standard and the RELATIVE programming
standard.
- Absolute programming standard
-
The absolute programming standards is a warning subset which excludes
erroneous constructions in the C programming language. QAC warnings
resulting from this warning subset must always be solved as they
represent real errors. The absolute programming standards applied to
ALL code.
- Relative programming standard
-
The relative programming standards is a warning subset which excludes
erroneous as well as dangerous constructions in the C programming
language. QAC warnings resulting from this warning subset must always be
solved as they represent problems with respect to run-time behavior or
maintenance aspects. The relative programming standards is more strict
than the absolute standard and must be applied to NEWLY developed code
of WDS.
By default the absolute programming standard is employed by qac_compiler.
The behavior of the qac_compiler script can be influenced by comment
lines in the code. By adding /* QAC APPLY RELATIVE */ in the source code,
the relative programming standard will be in effect will analyzing that
specific compilation unit (i.e. source code file). This is demonstrated
below:
/*
*
* blab bla
*
* QAC APPLY RELATIVE
*
*/
It does not matter where the ``QAC APPLY RELATIVE'' tag is located as long
it is somewhere in the code.
Suppression tags
It is important that warnings which can be ignored according to the
author of the code are suppressed. This can be achieved by adding a
comment with a suppression tag. A suppression tag is a specific comment
which is placed above the line resulting in the qac warning. This is
demonstrated by the next example:
/*
*
* Piece of code that has a fall through that must be suppressed
*
* QAC APPLY RELATIVE
*
*/
void jump( int location )
{
switch( location )
{
case 2:
{
printf("bye ");
}
/* fall through, QAC EXPECT 2003 */
case 1:
{
printf("bye ");
break;
}
default:
{
printf("ERROR);
break;
}
}
The regular expression of a QAC suppression tag is as follows :
".*\/*QAC\ *EXPECT\ *<nr_1>\ *((,\ *<nr_2>\ *)+)?\*\/"
The results of the QAC analysis are recorded in the .qac files. These
files can be analyzed using the qac_scan script. See qac_scan(1).
qac_scan
qac_scan is a script which reads the annotated .qac files resulting
from a static analysis with qac_compiler. The warnings are extracted and
suppressions annotated in the source will be effectuated. Warnings which
occur in the .qac file and that are not suppressed will be issued to
the stdout device.
Normally, the output format of qac_scan is he same as the gcc compiler
collection. This format is file,line,message. This allows the
programming to parse the output by an editor. It is also possible to
generate output in HTML output. Add -html as an optional argument
for this purpose.
Next: splint
Up: TUTTI Reference
Previous: Tutorial
  Contents
  Index
2004-05-28