![]() |
![]() |
2811 | ![]() |
||||
![]() | |||||||
| NULL pointers | |||||||
A definite anomaly has been detected. Examination of the context indicates that this expression will always result in the dereferencing of a null pointer. The result of any attempt to dereference a null pointer value is undefined. In the example below, p is NULL throughout the code contained in the "if" block and the result of the dereferencing operation will always be undefined.
/*PRQA S 504,2017,2983,2986,3199,3203,3227,3408,3412,3673,4600 ++*/
#define NULL (void *)0
void foo(int *p)
{
int r;
if (p == NULL)
{
r = *p; /* 2811 */
}
}
MISRA-C:2004 Rules applicable to message 2811:
| Rule 20.3 (Required) | The validity of values passed to library functions shall be checked. |
| Rule 21.1 (Required) | Minimisation of run-time failures shall be ensured by the use of at least one of (a) static analysis tools/techniques; (b) dynamic analysis tools/techniques; (c) explicit coding of checks to handle run-time faults |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |