diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-05-16 15:43:28 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-05-29 21:33:44 +0100 |
commit | 240943c65a1fbfe67cf5bd6bacb72076ffb6f1ce (patch) | |
tree | c17aebb0db54025784243e0588a0ad9d117ab151 /src/rtos/ThreadX.c | |
parent | 8446e140181e85bab82daa273c1637b1eab01bd5 (diff) | |
download | riscv-openocd-240943c65a1fbfe67cf5bd6bacb72076ffb6f1ce.zip riscv-openocd-240943c65a1fbfe67cf5bd6bacb72076ffb6f1ce.tar.gz riscv-openocd-240943c65a1fbfe67cf5bd6bacb72076ffb6f1ce.tar.bz2 |
rtos: use ARRAY_SIZE() and simplify rtos_type.create()
Use the existing macro ARRAY_SIZE().
Rewrite the functions rtos_type.create() to simplify the logic.
Change-Id: I8833354767045d1642801d26944c9087a77add00
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6261
Tested-by: jenkins
Diffstat (limited to 'src/rtos/ThreadX.c')
-rw-r--r-- | src/rtos/ThreadX.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c index 0b3fef0..53a74f8 100644 --- a/src/rtos/ThreadX.c +++ b/src/rtos/ThreadX.c @@ -65,7 +65,7 @@ static const struct ThreadX_thread_state ThreadX_thread_states[] = { { 13, "Waiting - Mutex" }, }; -#define THREADX_NUM_STATES (sizeof(ThreadX_thread_states)/sizeof(struct ThreadX_thread_state)) +#define THREADX_NUM_STATES ARRAY_SIZE(ThreadX_thread_states) #define ARM926EJS_REGISTERS_SIZE_SOLICITED (11 * 4) static const struct stack_register_offset rtos_threadx_arm926ejs_stack_offsets_solicited[] = { @@ -179,8 +179,6 @@ static const struct ThreadX_params ThreadX_params_list[] = { }, }; -#define THREADX_NUM_PARAMS ((int)(sizeof(ThreadX_params_list)/sizeof(struct ThreadX_params))) - enum ThreadX_symbol_values { ThreadX_VAL_tx_thread_current_ptr = 0, ThreadX_VAL_tx_thread_created_ptr = 1, @@ -599,18 +597,14 @@ static int ThreadX_get_thread_detail(struct rtos *rtos, static int ThreadX_create(struct target *target) { - int i = 0; - while ((i < THREADX_NUM_PARAMS) && - (0 != strcmp(ThreadX_params_list[i].target_name, target->type->name))) { - i++; - } - if (i >= THREADX_NUM_PARAMS) { - LOG_ERROR("Could not find target in ThreadX compatibility list"); - return -1; - } + for (unsigned int i = 0; i < ARRAY_SIZE(ThreadX_params_list); i++) + if (strcmp(ThreadX_params_list[i].target_name, target->type->name) == 0) { + target->rtos->rtos_specific_params = (void *)&ThreadX_params_list[i]; + target->rtos->current_thread = 0; + target->rtos->thread_details = NULL; + return 0; + } - target->rtos->rtos_specific_params = (void *) &ThreadX_params_list[i]; - target->rtos->current_thread = 0; - target->rtos->thread_details = NULL; - return 0; + LOG_ERROR("Could not find target in ThreadX compatibility list"); + return -1; } |