[rtems commit] score: Fix maybe uninitialized warning

Sebastian Huber sebh at rtems.org
Tue Feb 7 16:30:25 UTC 2023


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

Author:    Zhongjie Zhu <zhongjiezhu1 at gmail.com>
Date:      Mon Jan 16 16:36:54 2023 +0800

score: Fix maybe uninitialized warning

There are different cases for _ISR_lock_ISR_disable() and
_ISR_lock_ISR_enable() in the case RTEMS_SMP is defined or
RTEMS_PROFILING is defined, so remove the related code.

../../../cpukit/include/rtems/score/threaddispatch.h: In function '_Thread_Dispatch_disable':
../../../cpukit/include/rtems/score/threaddispatch.h:231:14: warning: 'lock_context' may be used uninitialized [-Wmaybe-uninitialized]
  231 |   cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../cpukit/include/rtems/score/threaddispatch.h:210:32: note: by argument 1 of type 'const ISR_lock_Context *' to '_Thread_Dispatch_disable_critical' declared here
  210 | static inline Per_CPU_Control *_Thread_Dispatch_disable_critical(
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../cpukit/include/rtems/score/threaddispatch.h:225:21: note: 'lock_context' declared here
  225 |   ISR_lock_Context  lock_context;
      |                     ^~~~~~~~~~~~

Update #4662.

---

 cpukit/include/rtems/score/threaddispatch.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/score/threaddispatch.h b/cpukit/include/rtems/score/threaddispatch.h
index 589935823f..b06ebe8fec 100644
--- a/cpukit/include/rtems/score/threaddispatch.h
+++ b/cpukit/include/rtems/score/threaddispatch.h
@@ -222,16 +222,17 @@ static inline Per_CPU_Control *_Thread_Dispatch_disable_critical(
 static inline Per_CPU_Control *_Thread_Dispatch_disable( void )
 {
   Per_CPU_Control  *cpu_self;
-  ISR_lock_Context  lock_context;
 
 #if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING )
+  ISR_lock_Context  lock_context;
+
   _ISR_lock_ISR_disable( &lock_context );
-#endif
 
   cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
 
-#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING )
   _ISR_lock_ISR_enable( &lock_context );
+#else
+  cpu_self = _Thread_Dispatch_disable_critical( NULL );
 #endif
 
   return cpu_self;



More information about the vc mailing list