aboutsummaryrefslogtreecommitdiff
path: root/src/rtos
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2020-08-24 11:42:15 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-05-29 21:33:23 +0100
commit8446e140181e85bab82daa273c1637b1eab01bd5 (patch)
tree769f3dc231ec31c873a89053370a6a6a125a46b8 /src/rtos
parent8f6dd512c7753ce1252283b208bb8f8880f93f37 (diff)
downloadriscv-openocd-8446e140181e85bab82daa273c1637b1eab01bd5.zip
riscv-openocd-8446e140181e85bab82daa273c1637b1eab01bd5.tar.gz
riscv-openocd-8446e140181e85bab82daa273c1637b1eab01bd5.tar.bz2
openocd: use macro ARRAY_SIZE()
There are still few cases where the macro ARRAY_SIZE() should be used in place of custom code. Use ARRAY_SIZE() whenever possible. Change-Id: Iba0127a02357bc704fe639e08562a4f9aa7011df Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6260 Reviewed-by: Xiang W <wxjstz@126.com> Tested-by: jenkins
Diffstat (limited to 'src/rtos')
-rw-r--r--src/rtos/mqx.c8
-rw-r--r--src/rtos/nuttx.c2
2 files changed, 4 insertions, 6 deletions
diff --git a/src/rtos/mqx.c b/src/rtos/mqx.c
index 22cd721..9f895de 100644
--- a/src/rtos/mqx.c
+++ b/src/rtos/mqx.c
@@ -267,8 +267,7 @@ static int mqx_create(
)
{
/* check target name against supported architectures */
- int mqx_params_list_num = (sizeof(mqx_params_list)/sizeof(struct mqx_params));
- for (int i = 0; i < mqx_params_list_num; i++) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(mqx_params_list); i++) {
if (0 == strcmp(mqx_params_list[i].target_name, target->type->name)) {
target->rtos->rtos_specific_params = (void *)&mqx_params_list[i];
/* LOG_DEBUG("MQX RTOS - valid architecture: %s", target->type->name); */
@@ -351,7 +350,7 @@ static int mqx_update_threads(
uint8_t task_name[MQX_THREAD_NAME_LENGTH + 1];
uint32_t task_addr = 0, task_template = 0, task_state = 0;
uint32_t task_name_addr = 0, task_id = 0, task_errno = 0;
- uint32_t state_index = 0, state_max = 0;
+ uint32_t state_index = 0;
uint32_t extra_info_length = 0;
char *state_name = "Unknown";
@@ -412,8 +411,7 @@ static int mqx_update_threads(
}
task_state &= MQX_TASK_STATE_MASK;
/* and search for defined state */
- state_max = (sizeof(mqx_states)/sizeof(struct mqx_state));
- for (state_index = 0; (state_index < state_max); state_index++) {
+ for (state_index = 0; state_index < ARRAY_SIZE(mqx_states); state_index++) {
if (mqx_states[state_index].state == task_state) {
state_name = mqx_states[state_index].name;
break;
diff --git a/src/rtos/nuttx.c b/src/rtos/nuttx.c
index 0705b17..c525471 100644
--- a/src/rtos/nuttx.c
+++ b/src/rtos/nuttx.c
@@ -314,7 +314,7 @@ static int nuttx_update_threads(struct rtos *rtos)
state = tcb.dat[state_offset - 8];
thread->extra_info_str = NULL;
- if (state < sizeof(task_state_str)/sizeof(char *)) {
+ if (state < ARRAY_SIZE(task_state_str)) {
thread->extra_info_str = malloc(256);
snprintf(thread->extra_info_str, 256, "pid:%d, %s",
tcb.dat[pid_offset - 8] |