[rtems commit] score: Improve assert
Sebastian Huber
sebh at rtems.org
Fri Apr 17 10:16:09 UTC 2015
Module: rtems
Branch: master
Commit: 41b37e00734f8144ee2a96a94421e12e0b4c20ea
Changeset: http://git.rtems.org/rtems/commit/?id=41b37e00734f8144ee2a96a94421e12e0b4c20ea
Author: Martin Galvan <martin.galvan at tallertechnologies.com>
Date: Fri Mar 27 10:08:10 2015 -0300
score: Improve assert
While cpu_self->thread_dispatch_disable_level shouldn't ever be zero, it
would be better to check it before doing the decrement.
---
cpukit/score/src/threaddispatchdisablelevel.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index 158fc39..f78eb52 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -107,11 +107,15 @@ uint32_t _Thread_Dispatch_decrement_disable_level( void )
cpu_self = _Per_CPU_Get();
disable_level = cpu_self->thread_dispatch_disable_level;
+ _Assert( disable_level > 0);
--disable_level;
cpu_self->thread_dispatch_disable_level = disable_level;
_Giant_Do_release( cpu_self );
- _Assert( disable_level != 0 || _Giant.owner_cpu != cpu_self );
+ _Assert(
+ ( disable_level == 0 && _Giant.owner_cpu != cpu_self )
+ || ( disable_level != 0 && _Giant.owner_cpu == cpu_self )
+ );
_Profiling_Thread_dispatch_enable( cpu_self, disable_level );
_ISR_Enable_without_giant( isr_level );
More information about the vc
mailing list