8 Categories of diagnostics with examples

Cadvise detects a wide range of coding errors and potential problems such as memory leaks, used after free, double free, array/buffer out of bounds access, illegal pointer access, un-initialized variables, unused variables, format string checks, suspicious conversion and casts, out of range operations, and C++ coding style warnings.

8.1 Categories of diagnostics table

Following are some examples of the various checks done by the HP Code Advisor:

+w

Enables all the warnings about potentially questionable constructs in the compiler.

+wall

Enables all the compile time checks.

“+wlint” (page 45)

Provides compile-time diagnostics which detect potential errors in the source code.

“+w64bit ” (page 51)

Enables warnings that help detection of potential problems in converting 32-bit

 

applications to 64-bit.

“+wendian” (page 51)

Detects code fragments which are endian dependent.

“+wsecurity[=1234]” (page 52) Enables compile time diagnostic messages for potential security vulnerabilities.

“+wlock” (page 53)

Detects multi-threaded programming issues.

“+wperfadvice[=1234]

Generates performance advisory diagnostics.

(page 54)

+w

This option enables all the warnings about potentially questionable constructs in the compiler. This includes the +wlint and +w64bit warnings and many others. The number of warnings generated by this option may be up to 5-10 times more than those generated by +wlint.

This option enables all the warnings about potentially questionable constructs in the compiler. This includes the +wlint and +w64bit warnings and many others. The number of warnings generated by this option may be up to 5-10 times more than those generated by +wlint.

Following are some examples of warnings enabled by the +w option:

-Variable is declared but never referenced

-Comparison of unsigned integer with signed integer

-Padding size of structure to alignment boundary

-Argument is incompatible with corresponding format string conversion

+wall

The +wall option enables all the compile time checks. The +wall option includes security checks and requires cross-module analysis. Hence, you must specify the location of the program database using the -pdboption, whenever you use +wall.

8.2Detecting generic programming errors

The compile time diagnostic messages generated by the +wlint option can be very useful in detecting potential problems in the source code. The number of warnings generated by this option may be up to 5-10 times more than those generated by default by the compiler. For example, the following warnings are enabled by this option:

-Argument is incompatible with formal parameter

-Function declared implicitly

-Function is re-declared after being called

8.1 Categories of diagnostics table

45

Page 45
Image 45
HP UX Web Development Tools manual Categories of diagnostics with examples, Categories of diagnostics table