From 5bb496bfeec16c91cbfa938c8c2b521b22fd039b Mon Sep 17 00:00:00 2001
From: Gregory Nutt Last Updated: July 6, 2019 Last Updated: January 2, 2020Table of Contents
NuttX C Coding Standard
- Returned Values
Checking Return Values.
Callers of internal OS functions should always check return values for an error.
At a minimum, a debug statement should indicate that an error has occurred.
- The calling logic intentionally ignores the returned value, then the function return value should be explicitly cast to (void) to indicate that the return value is intentionally ignored.
- An exception of for standard functions for which people have historically ignored the returned values, such as printf() or close.
- All calls to malloc or realloc must be checked for failures to allocate memory.
+ Ignored return values are always suspicious.
+ All calls to malloc or realloc, in particular, must be checked for failures to allocate memory to avoid use of NULL pointers.