Download Open Systems Portability Checker User Guide
Transcript
5.9.2 Implicit casts The C standard does not require that two types be exactly the same. In many circumstances an implicit cast will be inserted. Switching on this check will cause ‘suspicious’ implicit casts to be flagged. 5.9.3 Loop checks The C for statement is defined in terms of the while statement. Many coding standards mandate that the loop control variable only be modified within the loop header and not inside the compound statement. When this check is enabled mcc analyses loop headers looking for ‘suspicious’ constructs. 5.9.4 Appearance of a comment Many coding standards require that major language constructs be preceded by a comment. When enabled this coding standard option flags any major construct that is not preceded by a comment. 5.10 Metrics Software metrics do not give warnings about a specific source construct. Rather, they flag whole functions or expressions where a particular metric has exceeded some limit. The value of this limit being based on analysis of other code with a known problem history. Metrics are a statistical indicator of the likely hood of an error occurring in a portion of code. Another way to use metric information is to monitor how they change, for a given piece of software, over time. 5.10.1 Which metric? Many different measures of software complexity have been proposed. Interestingly many correlate very highly to lines of code. OSPC does not attempt to select among the competing metrics. Instead it focuses on producing the raw data from which most metrics can be calculated. This data is written to a .met file, if the -METrics option has been switched on. It is the job of other tools to calculate and display metric information. The source code of such a tool is provided in the software distributed with OSPC. The contents of a .met file are described in the Reference Manual. 5.10.2 dispmet The dispmet directory on the distribution tape contains the source of a program that takes a .met file and displays various metrics, using information from that file. To create an executable from the source provided use the make file provided as part of the distribution. Page 62