summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/stackchk/check.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-11-04 22:22:49 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-11-04 22:22:49 +0000
commit16b1546e0b02051c8b612d56449dd9703b860e9a (patch)
tree280180fc207f4dc90447fe74d493f9667f12ca0d /cpukit/libmisc/stackchk/check.c
parent2010-11-01 Alin Rus <alin.codejunkie@gmail.com> (diff)
downloadrtems-16b1546e0b02051c8b612d56449dd9703b860e9a.tar.bz2
2010-11-04 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/stackchk/check.c: Address casting issue highlighted by clang. There was no need for an intermediate cast to a structure pointer.
Diffstat (limited to '')
-rw-r--r--cpukit/libmisc/stackchk/check.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index 9bfc368be6..d8783ca96a 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -79,8 +79,8 @@ static inline bool Stack_check_Frame_pointer_in_range(
* whether the stack grow to the high or low area of the memory.
*/
#if (CPU_STACK_GROWS_UP == TRUE)
- #define Stack_check_Get_pattern_area( _the_stack ) \
- ((Stack_check_Control *) ((char *)(_the_stack)->area + \
+ #define Stack_check_Get_pattern( _the_stack ) \
+ ((char *)(_the_stack)->area + \
(_the_stack)->size - sizeof( Stack_check_Control ) ))
#define Stack_check_Calculate_used( _low, _size, _high_water ) \
@@ -96,8 +96,8 @@ static inline bool Stack_check_Frame_pointer_in_range(
* The task stack free operation will write the next and previous pointers
* for the free list into this area.
*/
- #define Stack_check_Get_pattern_area( _the_stack ) \
- ((Stack_check_Control *) ((char *)(_the_stack)->area \
+ #define Stack_check_Get_pattern( _the_stack ) \
+ ((char *)(_the_stack)->area \
+ sizeof(Heap_Block) - HEAP_BLOCK_HEADER_SIZE))
#define Stack_check_Calculate_used( _low, _size, _high_water) \
@@ -109,6 +109,12 @@ static inline bool Stack_check_Frame_pointer_in_range(
#endif
/*
+ * Obtain a properly typed pointer to the area to check.
+ */
+#define Stack_check_Get_pattern_area( _the_stack ) \
+ ((Stack_check_Control *) Stack_check_Get_pattern( _the_stack )
+
+/*
* The assumption is that if the pattern gets overwritten, the task
* is too close. This defines the usable stack memory.
*/
@@ -219,8 +225,8 @@ void Stack_check_report_blown_task(
void Stack_check_report_blown_task(Thread_Control *running, bool pattern_ok)
{
Stack_Control *stack = &running->Start.Initial_stack;
- void *pattern_area = Stack_check_Get_pattern_area(stack);
- char name [32];
+ void *pattern_area = Stack_check_Get_pattern(stack);
+ char name[32];
printk("BLOWN STACK!!!\n");
printk("task control block: 0x%08" PRIxPTR "\n", running);
@@ -270,10 +276,10 @@ void rtems_stack_checker_switch_extension(
{
Stack_Control *the_stack = &running->Start.Initial_stack;
void *pattern;
- bool sp_ok;
- bool pattern_ok = true;
+ bool sp_ok;
+ bool pattern_ok = true;
- pattern = (void *) Stack_check_Get_pattern_area(the_stack)->pattern;
+ pattern = Stack_check_Get_pattern_area(the_stack);
/*
* Check for an out of bounds stack pointer or an overwrite
@@ -309,7 +315,7 @@ bool rtems_stack_checker_is_blown( void )
*/
if ( Stack_check_Initialized ) {
pattern_ok = (!memcmp(
- (void *) Stack_check_Get_pattern_area(the_stack)->pattern,
+ Stack_check_Get_pattern(the_stack),
(void *) Stack_check_Pattern.pattern,
PATTERN_SIZE_BYTES
));