MISRA C:2023 Dir 4.11
The validity of values passed to library functions shall be checked
Since R2024a
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:
Invalid use of standard library integer routine
. Polyspace does not report a violation of this directive on invalid use of some integer library routines such asisalnum
,isalpha
, ortolower
.Invalid use of standard library memory routine
. Polyspace does not report a violation of this directive on invalid use of some memory library routines such asmemchr
,memcmp
, ormemset
.Invalid use of standard library string routine
. Polyspace does not report a violation of this directive on invalid use of some string library routines such asstrncat
,strncpy
, orstrcpy
.Invoking trigonometric functions from
math.h
using inputs outside the bound[-π,π]
.
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 R2024a