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
-#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);
static bool FreeRTOS_detect_rtos(struct target *target);
static int FreeRTOS_create(struct target *target);
static int FreeRTOS_update_threads(struct rtos *rtos);
static int FreeRTOS_create(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;
{ 13, "Waiting - Mutex" },
};
{ 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[] = {
#define ARM926EJS_REGISTERS_SIZE_SOLICITED (11 * 4)
static const struct stack_register_offset rtos_threadx_arm926ejs_stack_offsets_solicited[] = {
-#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,
enum ThreadX_symbol_values {
ThreadX_VAL_tx_thread_current_ptr = 0,
ThreadX_VAL_tx_thread_created_ptr = 1,
static int ThreadX_create(struct target *target)
{
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;
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"
};
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"
};
-#define CHIBIOS_NUM_STATES (sizeof(chibios_thread_states)/sizeof(char *))
+#define CHIBIOS_NUM_STATES ARRAY_SIZE(chibios_thread_states)
/* Maximum ChibiOS thread name. There is no real limit set by ChibiOS but 64
* chars ought to be enough.
/* Maximum ChibiOS thread name. There is no real limit set by ChibiOS but 64
* chars ought to be enough.
NULL, /* stacking_info */
}
};
NULL, /* stacking_info */
}
};
-#define CHIBIOS_NUM_PARAMS ((int)(sizeof(chibios_params_list)/sizeof(struct chibios_params)))
static bool chibios_detect_rtos(struct target *target);
static int chibios_create(struct target *target);
static bool chibios_detect_rtos(struct target *target);
static int chibios_create(struct target *target);
static int chibios_create(struct target *target)
{
static int chibios_create(struct target *target)
{
- int i = 0;
- while ((i < CHIBIOS_NUM_PARAMS) &&
- (0 != strcmp(chibios_params_list[i].target_name, target->type->name))) {
- i++;
- }
- if (i >= CHIBIOS_NUM_PARAMS) {
- LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
- "list", target->type->name);
- return -1;
- }
+ for (unsigned int i = 0; i < ARRAY_SIZE(chibios_params_list); i++)
+ if (strcmp(chibios_params_list[i].target_name, target->type->name) == 0) {
+ target->rtos->rtos_specific_params = (void *)&chibios_params_list[i];
+ return 0;
+ }
- target->rtos->rtos_specific_params = (void *) &chibios_params_list[i];
- return 0;
+ LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
+ "list", target->type->name);
+ return -1;
-#define ECOS_NUM_STATES (sizeof(eCos_thread_states)/sizeof(struct eCos_thread_state))
+#define ECOS_NUM_STATES ARRAY_SIZE(eCos_thread_states)
struct eCos_params {
const char *target_name;
struct eCos_params {
const char *target_name;
-#define ECOS_NUM_PARAMS ((int)(sizeof(eCos_params_list)/sizeof(struct eCos_params)))
-
enum eCos_symbol_values {
eCos_VAL_thread_list = 0,
eCos_VAL_current_thread_ptr = 1
enum eCos_symbol_values {
eCos_VAL_thread_list = 0,
eCos_VAL_current_thread_ptr = 1
static int eCos_create(struct target *target)
{
static int eCos_create(struct target *target)
{
- int i = 0;
- while ((i < ECOS_NUM_PARAMS) &&
- (0 != strcmp(eCos_params_list[i].target_name, target->type->name))) {
- i++;
- }
- if (i >= ECOS_NUM_PARAMS) {
- LOG_ERROR("Could not find target in eCos compatibility list");
- return -1;
- }
+ for (unsigned int i = 0; i < ARRAY_SIZE(eCos_params_list); i++)
+ if (strcmp(eCos_params_list[i].target_name, target->type->name) == 0) {
+ target->rtos->rtos_specific_params = (void *)&eCos_params_list[i];
+ target->rtos->current_thread = 0;
+ target->rtos->thread_details = NULL;
+ return 0;
+ }
- target->rtos->rtos_specific_params = (void *) &eCos_params_list[i];
- target->rtos->current_thread = 0;
- target->rtos->thread_details = NULL;
- return 0;
+ LOG_ERROR("Could not find target in eCos compatibility list");
+ return -1;
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)