Skip to content

Commit

Permalink
Fix nasa#651, use unsigned types in VxWorks stack calculation
Browse files Browse the repository at this point in the history
This should avoid any inconsistencies in the event that the
memory address translates to a negative numeric value.
  • Loading branch information
jphickey committed Nov 17, 2020
1 parent 7c1b59a commit 66ad32e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/os/vxworks/inc/os-impl-tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct
WIND_TCB tcb; /* Must be first */
TASK_ID vxid;
void * heap_block; /* set non-null if the stack was obtained with malloc() */
long heap_block_size;
size_t heap_block_size;
} OS_impl_task_internal_record_t;

/* Tables where the OS object information is stored */
Expand Down
12 changes: 6 additions & 6 deletions src/os/vxworks/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#if defined(_STACK_ALIGN_SIZE)
#define VX_IMPL_STACK_ALIGN_SIZE _STACK_ALIGN_SIZE
#else
#define VX_IMPL_STACK_ALIGN_SIZE 16
#define VX_IMPL_STACK_ALIGN_SIZE ((size_t)16)
#endif

#if defined(STACK_ROUND_DOWN)
Expand Down Expand Up @@ -122,9 +122,9 @@ int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags)
STATUS status;
int vxflags;
int vxpri;
long actualsz;
long userstackbase;
long actualstackbase;
size_t actualsz;
unsigned long userstackbase;
unsigned long actualstackbase;
OS_impl_task_internal_record_t *lrec;
VxWorks_ID_Buffer_t id;

Expand All @@ -147,7 +147,7 @@ int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags)
*/
vxpri = OS_task_table[task_id].priority;
actualsz = OS_task_table[task_id].stack_size;
userstackbase = (long)OS_task_table[task_id].stack_pointer;
userstackbase = (unsigned long)OS_task_table[task_id].stack_pointer;

/*
* NOTE: Using taskInit() here rather than taskSpawn() allows us
Expand Down Expand Up @@ -213,7 +213,7 @@ int32 OS_TaskCreate_Impl(uint32 task_id, uint32 flags)
}
}

userstackbase = (long)lrec->heap_block;
userstackbase = (unsigned long)lrec->heap_block;
}

if (userstackbase == 0)
Expand Down

0 comments on commit 66ad32e

Please sign in to comment.