[PATCH 01/20] apimutex.c: Add _Assert for NULL pointer access

Joel Sherrill joel.sherrill at oarcorp.com
Tue Nov 25 23:02:29 UTC 2014


From: Josh Oguin <josh.oguin at oarcorp.com>

CodeSonar detects a possible NULL deference here. But it should never
occur in tested code. Memory for the API Mutexes is reserved by confdefs.h
and are all preallocated when the class of objects is initialized.
Allocating a single instance should never fail.
---
 cpukit/score/src/apimutex.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/score/src/apimutex.c b/cpukit/score/src/apimutex.c
index ec2fbdc..eb0663d 100644
--- a/cpukit/score/src/apimutex.c
+++ b/cpukit/score/src/apimutex.c
@@ -61,6 +61,8 @@ void _API_Mutex_Allocate(
   mutex = (API_Mutex_Control *)
     _Objects_Allocate_unprotected( &_API_Mutex_Information );
 
+  _Assert( mutex != NULL );
+
   _CORE_mutex_Initialize( &mutex->Mutex, NULL, &attr, false );
 
   _Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 );
-- 
1.9.3




More information about the devel mailing list