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
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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))) {
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+6
-6
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+4
-4
@@ -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;
|
||||
|
||||
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user