[PATCH 3/3] posix: cleanup whitespace, alignment, and add copyrights for keys code.

Gedare Bloom gedare at rtems.org
Tue Mar 5 20:55:10 UTC 2013


---
 cpukit/posix/include/rtems/posix/key.h |   12 ++++----
 cpukit/posix/src/key.c                 |   45 +++++++++++++++-----------------
 cpukit/posix/src/keycreate.c           |   16 +++++-----
 cpukit/posix/src/keydelete.c           |   10 +++---
 cpukit/posix/src/keyfreememory.c       |   13 +++++----
 cpukit/posix/src/keygetspecific.c      |   21 ++++++++------
 cpukit/posix/src/keyrundestructors.c   |   31 ++++++++++++---------
 cpukit/posix/src/keysetspecific.c      |   11 ++++---
 8 files changed, 83 insertions(+), 76 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/key.h b/cpukit/posix/include/rtems/posix/key.h
index ab1fe04..38e7ca4 100644
--- a/cpukit/posix/include/rtems/posix/key.h
+++ b/cpukit/posix/include/rtems/posix/key.h
@@ -8,13 +8,13 @@
  */
 
 /*
- *  Copyright (c) 2012 Zhongwei Yao.
- *  COPYRIGHT (c) 1989-2011.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #ifndef _RTEMS_POSIX_KEY_H
diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c
index 177543d..47fdac9 100644
--- a/cpukit/posix/src/key.c
+++ b/cpukit/posix/src/key.c
@@ -6,12 +6,13 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2008.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
@@ -39,7 +40,7 @@
  * compare the pthread_key_t member. That is when we pass thread_id = 0 node
  * as a search node, the search is done only by pthread_key_t.
  *
- * @param[in] node1 The node to be compared *
+ * @param[in] node1 The node to be compared
  * @param[in] node2 The node to be compared
  * @retval positive if first node has higher key than second
  * @retval negative if lower
@@ -52,23 +53,21 @@ int _POSIX_Keys_Rbtree_compare_function(
   const RBTree_Node *node2
 )
 {
-  pthread_key_t key1 = _RBTree_Container_of(node1,
-                                           POSIX_Keys_Rbtree_node,
-                                           rb_node)->key;
-  pthread_key_t key2 = _RBTree_Container_of(node2,
-                                           POSIX_Keys_Rbtree_node,
-                                           rb_node)->key;
+  POSIX_Keys_Rbtree_node *n1;
+  POSIX_Keys_Rbtree_node *n2;
+  Objects_Id thread_id1, thread_id2;
+  int diff;
 
-  Objects_Id thread_id1 = _RBTree_Container_of(node1,
-                                              POSIX_Keys_Rbtree_node,
-                                              rb_node)->thread_id;
-  Objects_Id thread_id2 = _RBTree_Container_of(node2,
-                                              POSIX_Keys_Rbtree_node,
-                                              rb_node)->thread_id;
+  n1 = _RBTree_Container_of( node1, POSIX_Keys_Rbtree_node, rb_node );
+  n2 = _RBTree_Container_of( node2, POSIX_Keys_Rbtree_node, rb_node );
 
-  int diff = key1 - key2;
+  diff = n1->key - n2->key;
   if ( diff )
     return diff;
+
+  thread_id1 = n1->thread_id;
+  thread_id2 = n2->thread_id;
+
   /**
    * if thread_id1 or thread_id2 equals to 0, only key1 and key2 is valued.
    * it enables us search node only by pthread_key_t type key.
@@ -78,11 +77,9 @@ int _POSIX_Keys_Rbtree_compare_function(
   return 0;
 }
 
-
 /**
  * @brief This routine performs the initialization necessary for this manager.
  */
-
 void _POSIX_Key_Manager_initialization(void)
 {
   _Objects_Initialize_information(
@@ -103,8 +100,8 @@ void _POSIX_Key_Manager_initialization(void)
   );
 
   _RBTree_Initialize_empty(
-    &_POSIX_Keys_Rbtree,
-    _POSIX_Keys_Rbtree_compare_function,
-    true
+      &_POSIX_Keys_Rbtree,
+      _POSIX_Keys_Rbtree_compare_function,
+      true
   );
 }
diff --git a/cpukit/posix/src/keycreate.c b/cpukit/posix/src/keycreate.c
index 2d31d86..349e883 100644
--- a/cpukit/posix/src/keycreate.c
+++ b/cpukit/posix/src/keycreate.c
@@ -1,17 +1,17 @@
 /**
- *  @file
+ * @file
  *
- *  @brief Thread-Specific Data Key Create
- *  @ingroup POSIXAPI
+ * @brief Thread-Specific Data Key Create
+ * @ingroup POSIXAPI
  */
 
 /*
- *  COPYRIGHT (c) 1989-2010.
- *  On-Line Applications Research Corporation (OAR).
+ * COPYRIGHT (c) 1989-2010.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
diff --git a/cpukit/posix/src/keydelete.c b/cpukit/posix/src/keydelete.c
index ae15b7f..0e240da 100644
--- a/cpukit/posix/src/keydelete.c
+++ b/cpukit/posix/src/keydelete.c
@@ -6,12 +6,12 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
diff --git a/cpukit/posix/src/keyfreememory.c b/cpukit/posix/src/keyfreememory.c
index 5f7764b..40cca86 100644
--- a/cpukit/posix/src/keyfreememory.c
+++ b/cpukit/posix/src/keyfreememory.c
@@ -6,12 +6,13 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2010.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2010.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
@@ -34,7 +35,7 @@ void _POSIX_Keys_Free_memory(
 
   search_node.key = the_key->Object.id;
   search_node.thread_id = 0;
-  iter = _RBTree_Find_unprotected( &_POSIX_Keys_Rbtree, &search_node.rb_node);
+  iter = _RBTree_Find_unprotected( &_POSIX_Keys_Rbtree, &search_node.rb_node );
   if ( !iter )
     return;
   /**
diff --git a/cpukit/posix/src/keygetspecific.c b/cpukit/posix/src/keygetspecific.c
index eafa0ea..6cd3711 100644
--- a/cpukit/posix/src/keygetspecific.c
+++ b/cpukit/posix/src/keygetspecific.c
@@ -6,12 +6,13 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
@@ -48,12 +49,14 @@ void *pthread_getspecific(
     case OBJECTS_LOCAL:
       search_node.key = key;
       search_node.thread_id = _Thread_Executing->Object.id;
-      p = _RBTree_Find_unprotected( &_POSIX_Keys_Rbtree, &search_node.rb_node);
+      p = _RBTree_Find_unprotected( &_POSIX_Keys_Rbtree, &search_node.rb_node );
       key_data = NULL;
       if ( p ) {
-        key_data = _RBTree_Container_of( p,
-                                        POSIX_Keys_Rbtree_node,
-                                        rb_node )->value;
+        key_data = _RBTree_Container_of(
+            p,
+            POSIX_Keys_Rbtree_node,
+            rb_node
+        )->value;
       }
       _Thread_Enable_dispatch();
       return key_data;
diff --git a/cpukit/posix/src/keyrundestructors.c b/cpukit/posix/src/keyrundestructors.c
index a6e1090..43a74ac 100644
--- a/cpukit/posix/src/keyrundestructors.c
+++ b/cpukit/posix/src/keyrundestructors.c
@@ -6,14 +6,15 @@
  */
 
 /*
- *  Copyright (c) 2010 embedded brains GmbH.
+ * Copyright (c) 2012 Zhongwei Yao.
+ * Copyright (c) 2010 embedded brains GmbH.
  *
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
@@ -36,7 +37,6 @@
  *  NOTE:  This is the routine executed when a thread exits to
  *         run through all the keys and do the destructor action.
  */
-
 void _POSIX_Keys_Run_destructors(
   Thread_Control *thread
 )
@@ -50,8 +50,9 @@ void _POSIX_Keys_Run_destructors(
 
   _Thread_Disable_dispatch();
 
-  chain = &((POSIX_API_Control *)\
-           thread->API_Extensions[ THREAD_API_POSIX ])->Key_Chain;
+  chain = &(
+      (POSIX_API_Control *)thread->API_Extensions[ THREAD_API_POSIX ]
+  )->Key_Chain;
   iter = _Chain_First( chain );
   while ( !_Chain_Is_tail( chain, iter ) ) {
     next = _Chain_Next( iter );
@@ -61,15 +62,19 @@ void _POSIX_Keys_Run_destructors(
      * because Chain_Node is the first member of POSIX_Keys_Rbtree_node
      * structure.
      */
-    _RBTree_Extract_unprotected( &_POSIX_Keys_Rbtree,
-                                &((POSIX_Keys_Rbtree_node *)iter)->rb_node );
+    _RBTree_Extract_unprotected(
+        &_POSIX_Keys_Rbtree,
+        &((POSIX_Keys_Rbtree_node *)iter)->rb_node
+    );
     _Chain_Extract_unprotected( iter );
 
     /**
      * run key value's destructor if destructor and value are both non-null.
      */
-    the_key = _POSIX_Keys_Get( ((POSIX_Keys_Rbtree_node *)iter)->key,
-                              &location);
+    the_key = _POSIX_Keys_Get(
+        ((POSIX_Keys_Rbtree_node *)iter)->key,
+        &location
+    );
     destructor = the_key->destructor;
     value = ((POSIX_Keys_Rbtree_node *)iter)->value;
     if ( destructor != NULL && value != NULL )
diff --git a/cpukit/posix/src/keysetspecific.c b/cpukit/posix/src/keysetspecific.c
index eae1917..1b8381b 100644
--- a/cpukit/posix/src/keysetspecific.c
+++ b/cpukit/posix/src/keysetspecific.c
@@ -6,12 +6,13 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (c) 2012 Zhongwei Yao.
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
  */
 
 #if HAVE_CONFIG_H
-- 
1.7.1




More information about the devel mailing list