Main Content

MISRA C:2012 Dir 4.11

The validity of values passed to library functions shall be checked

Description

Directive Definition

The validity of values passed to library functions shall be checked.

Rationale

Many Standard C functions do not check the validity of parameters passed to them. Even if checks are performed by a compiler, there is no guarantee that the checks are adequate. For example, you should not pass negative numbers to sqrt or log.

Polyspace Implementation

Polyspace® reports violation of this directive if any of these issues are detected:

Tip

To mass-justify all results related to the same library function, use the Detail column on the Results List pane. Click the column header so that all results with the same entry are grouped together. Select the first result and then select the last result while holding the Shift key. Assign a status to one of the results. If you do not see the Detail column, right-click any other column header and enable this column.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Code design
Category: Required
AGC Category: Required

Version History

Introduced in R2014b

expand all