[rtems commit] chainimpl.h: Add _Assert() to _Chain_Initialize_empty()

Joel Sherril joel at rtems.org
Wed Nov 26 13:55:51 UTC 2014


Module:    rtems
Branch:    master
Commit:    fbafb8f249b5e485ff7ec539eb614aa42a9a647e
Changeset: http://git.rtems.org/rtems/commit/?id=fbafb8f249b5e485ff7ec539eb614aa42a9a647e

Author:    Josh Oguin <josh.oguin at oarcorp.com>
Date:      Wed Nov 19 14:46:43 2014 -0600

chainimpl.h: Add _Assert() to _Chain_Initialize_empty()

CodeSonar flagged this as a potential NULL deference. That should never
occur but adding the _Assert() ensures we are checking that.

---

 cpukit/score/include/rtems/score/chainimpl.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/cpukit/score/include/rtems/score/chainimpl.h b/cpukit/score/include/rtems/score/chainimpl.h
index 6e1b6e3..08cbab6 100644
--- a/cpukit/score/include/rtems/score/chainimpl.h
+++ b/cpukit/score/include/rtems/score/chainimpl.h
@@ -7,7 +7,7 @@
 /*
  *  Copyright (c) 2010 embedded brains GmbH.
  *
- *  COPYRIGHT (c) 1989-2006.
+ *  COPYRIGHT (c) 1989-2014.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -20,6 +20,7 @@
 
 #include <rtems/score/chain.h>
 #include <rtems/score/address.h>
+#include <rtems/score/assert.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -613,8 +614,13 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(
   Chain_Control *the_chain
 )
 {
-  Chain_Node *head = _Chain_Head( the_chain );
-  Chain_Node *tail = _Chain_Tail( the_chain );
+  Chain_Node *head;
+  Chain_Node *tail;
+
+  _Assert( the_chain != NULL );
+
+  head = _Chain_Head( the_chain );
+  tail = _Chain_Tail( the_chain );
 
   head->next = tail;
   head->previous = NULL;




More information about the vc mailing list