diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 21:29:32 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-24 10:38:00 +0100 |
commit | 391782318723915bd259eadf9469251c13c8fa9c (patch) | |
tree | df5fe28d94e46fd98bf54f47152034db5696f5da /src/rtos | |
parent | 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (diff) | |
download | riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.zip riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.gz riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.bz2 |
openocd: remove NULL comparisons with checkpatch [1/2]
Patch generated automatically through the new checkpatch with
flags "--types COMPARISON_TO_NULL --fix-inplace".
This only fixes the comparisons
if (symbol == NULL)
if (symbol != NULL)
The case of NULL on the left side of the comparison is not tested.
Some automatic fix is incorrect and has been massaged by hands:
- if (*psig == NULL)
+ if (*!psig)
changed as
+ if (!*psig)
Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6351
Tested-by: jenkins
Diffstat (limited to 'src/rtos')
-rw-r--r-- | src/rtos/FreeRTOS.c | 2 | ||||
-rw-r--r-- | src/rtos/ThreadX.c | 2 | ||||
-rw-r--r-- | src/rtos/chibios.c | 4 | ||||
-rw-r--r-- | src/rtos/eCos.c | 2 | ||||
-rw-r--r-- | src/rtos/embKernel.c | 2 | ||||
-rw-r--r-- | src/rtos/hwthread.c | 12 | ||||
-rw-r--r-- | src/rtos/linux.c | 2 | ||||
-rw-r--r-- | src/rtos/mqx.c | 2 | ||||
-rw-r--r-- | src/rtos/nuttx.c | 2 | ||||
-rw-r--r-- | src/rtos/riot.c | 8 | ||||
-rw-r--r-- | src/rtos/rtos.c | 10 | ||||
-rw-r--r-- | src/rtos/uCOS-III.c | 4 | ||||
-rw-r--r-- | src/rtos/zephyr.c | 2 |
13 files changed, 27 insertions, 27 deletions
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c index 87b1681..f7ce8cd 100644 --- a/src/rtos/FreeRTOS.c +++ b/src/rtos/FreeRTOS.c @@ -531,7 +531,7 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i static bool freertos_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && (target->rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address != 0)) { /* looks like FreeRTOS */ return true; diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c index c7effe7..788edc0 100644 --- a/src/rtos/ThreadX.c +++ b/src/rtos/ThreadX.c @@ -491,7 +491,7 @@ static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li static bool threadx_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && (target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) { /* looks like ThreadX */ return true; diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c index 6539a78..ef1f34d 100644 --- a/src/rtos/chibios.c +++ b/src/rtos/chibios.c @@ -500,7 +500,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li { *symbol_list = malloc(sizeof(chibios_symbol_list)); - if (*symbol_list == NULL) + if (!*symbol_list) return ERROR_FAIL; memcpy(*symbol_list, chibios_symbol_list, sizeof(chibios_symbol_list)); @@ -509,7 +509,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li static bool chibios_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && ((target->rtos->symbols[CHIBIOS_VAL_RLIST].address != 0) || (target->rtos->symbols[CHIBIOS_VAL_CH].address != 0))) { diff --git a/src/rtos/eCos.c b/src/rtos/eCos.c index c6b2628..a81d7b9 100644 --- a/src/rtos/eCos.c +++ b/src/rtos/eCos.c @@ -363,7 +363,7 @@ static int ecos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[ static bool ecos_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && (target->rtos->symbols[ECOS_VAL_THREAD_LIST].address != 0)) { /* looks like eCos */ return true; diff --git a/src/rtos/embKernel.c b/src/rtos/embKernel.c index 1987fd5..85c8d19 100644 --- a/src/rtos/embKernel.c +++ b/src/rtos/embKernel.c @@ -110,7 +110,7 @@ static const struct embkernel_params embkernel_params_list[] = { static bool embkernel_detect_rtos(struct target *target) { - if (target->rtos->symbols != NULL) { + if (target->rtos->symbols) { if (target->rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address != 0) return true; } diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index 5732ac2..3702b0b 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -107,7 +107,7 @@ static int hwthread_update_threads(struct rtos *rtos) /* determine the number of "threads" */ if (target->smp) { - for (head = target->head; head != NULL; head = head->next) { + for (head = target->head; head; head = head->next) { struct target *curr = head->target; if (!target_was_examined(curr)) @@ -123,7 +123,7 @@ static int hwthread_update_threads(struct rtos *rtos) if (target->smp) { /* loop over all threads */ - for (head = target->head; head != NULL; head = head->next) { + for (head = target->head; head; head = head->next) { struct target *curr = head->target; if (!target_was_examined(curr)) @@ -218,7 +218,7 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread if (!target) return NULL; if (target->smp) { - for (struct target_list *head = target->head; head != NULL; head = head->next) { + for (struct target_list *head = target->head; head; head = head->next) { if (thread_id == threadid_from_target(head->target)) return head->target; } @@ -252,20 +252,20 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id, int j = 0; for (int i = 0; i < reg_list_size; i++) { - if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) continue; j++; } *rtos_reg_list_size = j; *rtos_reg_list = calloc(*rtos_reg_list_size, sizeof(struct rtos_reg)); - if (*rtos_reg_list == NULL) { + if (!*rtos_reg_list) { free(reg_list); return ERROR_FAIL; } j = 0; for (int i = 0; i < reg_list_size; i++) { - if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden) + if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden) continue; (*rtos_reg_list)[j].number = (*reg_list)[i].number; (*rtos_reg_list)[j].size = (*reg_list)[i].size; diff --git a/src/rtos/linux.c b/src/rtos/linux.c index b9749b5..11a55c4 100644 --- a/src/rtos/linux.c +++ b/src/rtos/linux.c @@ -639,7 +639,7 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads { t->next = NULL; - if (*last == NULL) + if (!*last) if (!task_list) { task_list = t; return task_list; diff --git a/src/rtos/mqx.c b/src/rtos/mqx.c index f6be35b..710436b 100644 --- a/src/rtos/mqx.c +++ b/src/rtos/mqx.c @@ -243,7 +243,7 @@ static bool mqx_detect_rtos( ) { if ( - (target->rtos->symbols != NULL) && + (target->rtos->symbols) && (target->rtos->symbols[MQX_VAL_MQX_KERNEL_DATA].address != 0) ) { return true; diff --git a/src/rtos/nuttx.c b/src/rtos/nuttx.c index 00fec7f..cc352d1 100644 --- a/src/rtos/nuttx.c +++ b/src/rtos/nuttx.c @@ -233,7 +233,7 @@ retok: static bool nuttx_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && (target->rtos->symbols[0].address != 0) && (target->rtos->symbols[1].address != 0)) { return true; diff --git a/src/rtos/riot.c b/src/rtos/riot.c index 2316f17..6652db6 100644 --- a/src/rtos/riot.c +++ b/src/rtos/riot.c @@ -255,7 +255,7 @@ static int riot_update_threads(struct rtos *rtos) strdup(riot_thread_states[k].desc); } - if (rtos->thread_details[tasks_found].extra_info_str == NULL) { + if (!rtos->thread_details[tasks_found].extra_info_str) { LOG_ERROR("RIOT: out of memory"); retval = ERROR_FAIL; goto error; @@ -297,7 +297,7 @@ static int riot_update_threads(struct rtos *rtos) strdup("Enable DEVELHELP to see task names"); } - if (rtos->thread_details[tasks_found].thread_name_str == NULL) { + if (!rtos->thread_details[tasks_found].thread_name_str) { LOG_ERROR("RIOT: out of memory"); retval = ERROR_FAIL; goto error; @@ -364,7 +364,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[ { *symbol_list = calloc(ARRAY_SIZE(riot_symbol_list), sizeof(struct symbol_table_elem)); - if (*symbol_list == NULL) { + if (!*symbol_list) { LOG_ERROR("RIOT: out of memory"); return ERROR_FAIL; } @@ -387,7 +387,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[ static bool riot_detect_rtos(struct target *target) { - if ((target->rtos->symbols != NULL) && + if ((target->rtos->symbols) && (target->rtos->symbols[RIOT_THREADS_BASE].address != 0)) { /* looks like RIOT */ return true; diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 54e9926..2b62154 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -306,13 +306,13 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa struct target *target = get_target_from_connection(connection); if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) { - if ((target->rtos) && (target->rtos->thread_details != NULL) && + if ((target->rtos) && (target->rtos->thread_details) && (target->rtos->thread_count != 0)) { threadid_t threadid = 0; int found = -1; sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid); - if ((target->rtos) && (target->rtos->thread_details != NULL)) { + if ((target->rtos) && (target->rtos->thread_details)) { int thread_num; for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) { if (target->rtos->thread_details[thread_num].threadid == threadid) { @@ -416,7 +416,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa threadid_t threadid; int found = -1; sscanf(packet, "T%" SCNx64, &threadid); - if ((target->rtos) && (target->rtos->thread_details != NULL)) { + if ((target->rtos) && (target->rtos->thread_details)) { int thread_num; for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) { if (target->rtos->thread_details[thread_num].threadid == threadid) { @@ -564,7 +564,7 @@ int rtos_set_reg(struct connection *connection, int reg_num, struct target *target = get_target_from_connection(connection); int64_t current_threadid = target->rtos->current_threadid; if ((target->rtos) && - (target->rtos->type->set_reg != NULL) && + (target->rtos->type->set_reg) && (current_threadid != -1) && (current_threadid != 0)) { return target->rtos->type->set_reg(target->rtos, reg_num, reg_value); @@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target) int rtos_update_threads(struct target *target) { - if ((target->rtos) && (target->rtos->type != NULL)) + if ((target->rtos) && (target->rtos->type)) target->rtos->type->update_threads(target->rtos); return ERROR_OK; } diff --git a/src/rtos/uCOS-III.c b/src/rtos/uCOS-III.c index 4cdf72d..385c8d8 100644 --- a/src/rtos/uCOS-III.c +++ b/src/rtos/uCOS-III.c @@ -257,7 +257,7 @@ static int ucos_iii_update_thread_offsets(struct rtos *rtos) static bool ucos_iii_detect_rtos(struct target *target) { - return target->rtos->symbols != NULL && + return target->rtos->symbols && target->rtos->symbols[UCOS_III_VAL_OS_RUNNING].address != 0; } @@ -511,7 +511,7 @@ static int ucos_iii_get_thread_reg_list(struct rtos *rtos, threadid_t threadid, static int ucos_iii_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[]) { *symbol_list = calloc(ARRAY_SIZE(ucos_iii_symbol_list), sizeof(struct symbol_table_elem)); - if (*symbol_list == NULL) { + if (!*symbol_list) { LOG_ERROR("uCOS-III: out of memory"); return ERROR_FAIL; } diff --git a/src/rtos/zephyr.c b/src/rtos/zephyr.c index ef5ff58..fc5e037 100644 --- a/src/rtos/zephyr.c +++ b/src/rtos/zephyr.c @@ -385,7 +385,7 @@ static const struct symbol_table_elem zephyr_symbol_list[] = { static bool zephyr_detect_rtos(struct target *target) { - if (target->rtos->symbols == NULL) { + if (!target->rtos->symbols) { LOG_INFO("Zephyr: no symbols while detecting RTOS"); return false; } |