[PATCH] config: CONFIGURE_DISABLE_NEWLIB_REENTRANCY

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 18 15:39:00 UTC 2022


Do not initialize Thread_Control::libc_reent if
CONFIGURE_DISABLE_NEWLIB_REENTRANCY is defined.  This helps to catch errors
with a NULL pointer exception rather than a corruption of the thread control
block.
---
 cpukit/include/rtems/confdefs/threads.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/cpukit/include/rtems/confdefs/threads.h b/cpukit/include/rtems/confdefs/threads.h
index 279c6264db..503a4b20ec 100644
--- a/cpukit/include/rtems/confdefs/threads.h
+++ b/cpukit/include/rtems/confdefs/threads.h
@@ -161,8 +161,6 @@ struct Thread_Configured_control {
   #endif
   #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
     struct _reent Newlib;
-  #else
-    struct { /* Empty */ } Newlib;
   #endif
 };
 
@@ -176,13 +174,16 @@ const Thread_Control_add_on _Thread_Control_add_ons[] = {
       Control.API_Extensions[ THREAD_API_RTEMS ]
     ),
     offsetof( Thread_Configured_control, API_RTEMS )
-  }, {
-    offsetof(
-      Thread_Configured_control,
-      Control.libc_reent
-    ),
-    offsetof( Thread_Configured_control, Newlib )
   }
+  #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
+    , {
+      offsetof(
+        Thread_Configured_control,
+        Control.libc_reent
+      ),
+      offsetof( Thread_Configured_control, Newlib )
+    }
+  #endif
   #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
     , {
       offsetof(
-- 
2.26.2



More information about the devel mailing list