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
This commit is contained in:
Antonio Borneo
2021-05-16 15:43:28 +02:00
parent 8446e14018
commit 240943c65a
4 changed files with 36 additions and 59 deletions

View File

@@ -102,8 +102,6 @@ static const struct FreeRTOS_params FreeRTOS_params_list[] = {
},
};
#define FREERTOS_NUM_PARAMS ((int)(sizeof(FreeRTOS_params_list)/sizeof(struct FreeRTOS_params)))
static bool FreeRTOS_detect_rtos(struct target *target);
static int FreeRTOS_create(struct target *target);
static int FreeRTOS_update_threads(struct rtos *rtos);
@@ -547,16 +545,12 @@ static bool FreeRTOS_detect_rtos(struct target *target)
static int FreeRTOS_create(struct target *target)
{
int i = 0;
while ((i < FREERTOS_NUM_PARAMS) &&
(0 != strcmp(FreeRTOS_params_list[i].target_name, target->type->name))) {
i++;
}
if (i >= FREERTOS_NUM_PARAMS) {
LOG_ERROR("Could not find target in FreeRTOS compatibility list");
return -1;
}
for (unsigned int i = 0; i < ARRAY_SIZE(FreeRTOS_params_list); i++)
if (strcmp(FreeRTOS_params_list[i].target_name, target->type->name) == 0) {
target->rtos->rtos_specific_params = (void *)&FreeRTOS_params_list[i];
return 0;
}
target->rtos->rtos_specific_params = (void *) &FreeRTOS_params_list[i];
return 0;
LOG_ERROR("Could not find target in FreeRTOS compatibility list");
return -1;
}