aboutsummaryrefslogtreecommitdiff
path: root/src/rtos
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-07-03 18:51:20 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-07-24 10:37:49 +0100
commit08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (patch)
treea824d376b774499303f00cffb201e35b01830d98 /src/rtos
parentb159f5cdedd70fff9309722e927be670845f4df5 (diff)
downloadriscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.zip
riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.gz
riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.bz2
openocd: fix simple cases of NULL comparison
There are more than 1000 NULL comparisons to be aligned to the coding style. For recurrent NULL comparison it's preferable using trivial scripts in order to minimize the review effort. Patch generated automatically with the command: sed -i PATTERN $(find src/ -type f) where PATTERN is in the list: 's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g' Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins
Diffstat (limited to 'src/rtos')
-rw-r--r--src/rtos/FreeRTOS.c12
-rw-r--r--src/rtos/ThreadX.c24
-rw-r--r--src/rtos/chibios.c4
-rw-r--r--src/rtos/eCos.c10
-rw-r--r--src/rtos/embKernel.c10
-rw-r--r--src/rtos/hwthread.c18
-rw-r--r--src/rtos/linux.c72
-rw-r--r--src/rtos/mqx.c2
-rw-r--r--src/rtos/nuttx.c2
-rw-r--r--src/rtos/riot.c12
-rw-r--r--src/rtos/rtos.c32
-rw-r--r--src/rtos/uCOS-III.c8
-rw-r--r--src/rtos/zephyr.c4
13 files changed, 105 insertions, 105 deletions
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c
index a480c44..87b1681 100644
--- a/src/rtos/FreeRTOS.c
+++ b/src/rtos/FreeRTOS.c
@@ -160,12 +160,12 @@ static int freertos_update_threads(struct rtos *rtos)
unsigned int tasks_found = 0;
const struct freertos_params *param;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct freertos_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for FreeRTOS");
return -3;
}
@@ -403,13 +403,13 @@ static int freertos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
const struct freertos_params *param;
int64_t stack_ptr = 0;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct freertos_params *) rtos->rtos_specific_params;
@@ -494,13 +494,13 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i
int retval;
const struct freertos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct freertos_params *) rtos->rtos_specific_params;
diff --git a/src/rtos/ThreadX.c b/src/rtos/ThreadX.c
index 5eadce9..c7effe7 100644
--- a/src/rtos/ThreadX.c
+++ b/src/rtos/ThreadX.c
@@ -206,7 +206,7 @@ static const struct rtos_register_stacking *get_stacking_info(const struct rtos
{
const struct threadx_params *param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (param->fn_get_stacking_info != NULL)
+ if (param->fn_get_stacking_info)
return param->fn_get_stacking_info(rtos, stack_ptr);
return param->stacking_info + 0;
@@ -216,12 +216,12 @@ static int is_thread_id_valid(const struct rtos *rtos, int64_t thread_id)
{
const struct threadx_params *param;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return 0; /* invalid */
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (param->fn_is_thread_id_valid != NULL)
+ if (param->fn_is_thread_id_valid)
return param->fn_is_thread_id_valid(rtos, thread_id);
return (thread_id != 0);
@@ -263,15 +263,15 @@ static int threadx_update_threads(struct rtos *rtos)
int thread_list_size = 0;
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for ThreadX");
return -4;
}
@@ -437,13 +437,13 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
int retval;
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (!is_thread_id_valid(rtos, thread_id))
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
@@ -469,7 +469,7 @@ static int threadx_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
const struct rtos_register_stacking *stacking_info =
get_stacking_info(rtos, stack_ptr);
- if (stacking_info == NULL) {
+ if (!stacking_info) {
LOG_ERROR("Unknown stacking info for thread id=0x%" PRIx64, (uint64_t)thread_id);
return -6;
}
@@ -518,18 +518,18 @@ static int threadx_get_thread_detail(struct rtos *rtos,
const struct threadx_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct threadx_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for ThreadX");
return -3;
}
diff --git a/src/rtos/chibios.c b/src/rtos/chibios.c
index cb471b4..6539a78 100644
--- a/src/rtos/chibios.c
+++ b/src/rtos/chibios.c
@@ -469,8 +469,8 @@ static int chibios_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
const struct chibios_params *param;
uint32_t stack_ptr = 0;
- if ((rtos == NULL) || (thread_id == 0) ||
- (rtos->rtos_specific_params == NULL))
+ if ((!rtos) || (thread_id == 0) ||
+ (!rtos->rtos_specific_params))
return -1;
param = (const struct chibios_params *) rtos->rtos_specific_params;
diff --git a/src/rtos/eCos.c b/src/rtos/eCos.c
index b060a81..c6b2628 100644
--- a/src/rtos/eCos.c
+++ b/src/rtos/eCos.c
@@ -102,15 +102,15 @@ static int ecos_update_threads(struct rtos *rtos)
int thread_list_size = 0;
const struct ecos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct ecos_params *) rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for eCos");
return -4;
}
@@ -289,13 +289,13 @@ static int ecos_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
int retval;
const struct ecos_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
param = (const struct ecos_params *) rtos->rtos_specific_params;
diff --git a/src/rtos/embKernel.c b/src/rtos/embKernel.c
index 259399b..1987fd5 100644
--- a/src/rtos/embKernel.c
+++ b/src/rtos/embKernel.c
@@ -187,13 +187,13 @@ static int embkernel_update_threads(struct rtos *rtos)
int retval;
const struct embkernel_params *param;
- if (rtos == NULL)
+ if (!rtos)
return -1;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -3;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for embKernel");
return -4;
}
@@ -308,13 +308,13 @@ static int embkernel_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
const struct embkernel_params *param;
int64_t stack_ptr = 0;
- if (rtos == NULL)
+ if (!rtos)
return -1;
if (thread_id == 0)
return -2;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return -1;
param = (const struct embkernel_params *) rtos->rtos_specific_params;
diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c
index dfa247f..5732ac2 100644
--- a/src/rtos/hwthread.c
+++ b/src/rtos/hwthread.c
@@ -97,7 +97,7 @@ static int hwthread_update_threads(struct rtos *rtos)
int64_t current_thread = 0;
enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
- if (rtos == NULL)
+ if (!rtos)
return -1;
target = rtos->target;
@@ -215,7 +215,7 @@ static int hwthread_smp_init(struct target *target)
static struct target *hwthread_find_thread(struct target *target, int64_t thread_id)
{
/* Find the thread with that thread_id */
- if (target == NULL)
+ if (!target)
return NULL;
if (target->smp) {
for (struct target_list *head = target->head; head != NULL; head = head->next) {
@@ -231,13 +231,13 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread
static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
struct rtos_reg **rtos_reg_list, int *rtos_reg_list_size)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
if (!target_was_examined(curr))
@@ -281,13 +281,13 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
uint32_t reg_num, struct rtos_reg *rtos_reg)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL) {
+ if (!curr) {
LOG_ERROR("Couldn't find RTOS thread for id %" PRId64 ".", thread_id);
return ERROR_FAIL;
}
@@ -318,13 +318,13 @@ static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
static int hwthread_set_reg(struct rtos *rtos, uint32_t reg_num, uint8_t *reg_value)
{
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
struct target *target = rtos->target;
struct target *curr = hwthread_find_thread(target, rtos->current_thread);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
struct reg *reg = register_get_by_number(curr->reg_cache, reg_num, true);
@@ -347,7 +347,7 @@ static int hwthread_target_for_threadid(struct connection *connection, int64_t t
struct target *target = get_target_from_connection(connection);
struct target *curr = hwthread_find_thread(target, thread_id);
- if (curr == NULL)
+ if (!curr)
return ERROR_FAIL;
*p_target = curr;
diff --git a/src/rtos/linux.c b/src/rtos/linux.c
index 0a15efa..b9749b5 100644
--- a/src/rtos/linux.c
+++ b/src/rtos/linux.c
@@ -181,7 +181,7 @@ static int linux_os_thread_reg_list(struct rtos *rtos,
found = 1;
else
next = next->next;
- } while ((found == 0) && (next != tmp) && (next != NULL));
+ } while ((found == 0) && (next != tmp) && (next));
if (found == 0) {
LOG_ERROR("could not find thread: %" PRIx64, thread_id);
@@ -408,7 +408,7 @@ static int get_current(struct target *target, int create)
struct current_thread *ctt = linux_os->current_threads;
/* invalid current threads content */
- while (ctt != NULL) {
+ while (ctt) {
ctt->threadid = -1;
ctt->TS = 0xdeadbeef;
ctt = ctt->next;
@@ -445,10 +445,10 @@ static int get_current(struct target *target, int create)
linux_os->current_threads;
cpu = head->target->coreid;
- while ((ct != NULL) && (ct->core_id != (int32_t) cpu))
+ while ((ct) && (ct->core_id != (int32_t) cpu))
ct = ct->next;
- if ((ct != NULL) && (ct->TS == 0xdeadbeef))
+ if ((ct) && (ct->TS == 0xdeadbeef))
ct->TS = TS;
else
LOG_ERROR
@@ -603,13 +603,13 @@ static struct current_thread *add_current_thread(struct current_thread *currents
{
ct->next = NULL;
- if (currents == NULL) {
+ if (!currents) {
currents = ct;
return currents;
} else {
struct current_thread *temp = currents;
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
temp->next = ct;
@@ -640,13 +640,13 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads
t->next = NULL;
if (*last == NULL)
- if (task_list == NULL) {
+ if (!task_list) {
task_list = t;
return task_list;
} else {
struct threads *temp = task_list;
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
temp->next = t;
@@ -668,15 +668,15 @@ static int current_base_addr(struct linux_os *linux_os, uint32_t base_addr)
struct current_thread *ct = linux_os->current_threads;
#ifdef PID_CHECK
- while ((ct != NULL) && (ct->pid != pid))
+ while ((ct) && (ct->pid != pid))
#else
- while ((ct != NULL) && (ct->TS != base_addr))
+ while ((ct) && (ct->TS != base_addr))
#endif
ct = ct->next;
#ifdef PID_CHECK
- if ((ct != NULL) && (ct->pid == pid))
+ if ((ct) && (ct->pid == pid))
#else
- if ((ct != NULL) && (ct->TS == base_addr))
+ if ((ct) && (ct->TS == base_addr))
#endif
return 1;
@@ -777,7 +777,7 @@ static int clean_threadlist(struct target *target)
target->rtos->rtos_specific_params;
struct threads *old, *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
old = temp;
free(temp->context);
@@ -815,10 +815,10 @@ static int insert_into_threadlist(struct target *target, struct threads *t)
t->status = 1;
t->next = NULL;
- if (temp == NULL)
+ if (!temp)
linux_os->thread_list = t;
else {
- while (temp->next != NULL)
+ while (temp->next)
temp = temp->next;
t->next = NULL;
@@ -836,7 +836,7 @@ static void linux_identify_current_threads(struct target *target)
struct current_thread *ct = linux_os->current_threads;
struct threads *t = NULL;
- while ((ct != NULL)) {
+ while ((ct)) {
if (ct->threadid == -1) {
/* un-identified thread */
@@ -856,7 +856,7 @@ error_handling:
/* search in the list of threads if pid
already present */
- while ((thread_list != NULL) && (found == 0)) {
+ while ((thread_list) && (found == 0)) {
#ifdef PID_CHECK
if (thread_list->pid == t->pid) {
#else
@@ -926,7 +926,7 @@ static int linux_task_update(struct target *target, int context)
linux_os->thread_count = 0;
/*thread_list = thread_list->next; skip init_task*/
- while (thread_list != NULL) {
+ while (thread_list) {
thread_list->status = 0; /*setting all tasks to dead state*/
free(thread_list->context);
@@ -967,7 +967,7 @@ static int linux_task_update(struct target *target, int context)
thread_list = linux_os->thread_list;
- while (thread_list != NULL) {
+ while (thread_list) {
#ifdef PID_CHECK
if (t->pid == thread_list->pid) {
#else
@@ -1058,7 +1058,7 @@ static int linux_gdb_thread_packet(struct target *target,
tmp_str += sprintf(tmp_str, "m");
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
tmp_str += sprintf(tmp_str, "%016" PRIx64, temp->threadid);
temp = temp->next;
if (temp)
@@ -1079,7 +1079,7 @@ static int linux_gdb_thread_update(struct target *target,
target->rtos->rtos_specific_params;
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == linux_os->preupdtate_threadid_count + 1) {
/*LOG_INFO("FOUND");*/
found = 1;
@@ -1098,7 +1098,7 @@ static int linux_gdb_thread_update(struct target *target,
temp = temp->next;
- while (temp != NULL) {
+ while (temp) {
/*LOG_INFO("INTO GDB THREAD UPDATE WHILE");*/
tmp_strr += sprintf(tmp_strr, ",");
tmp_strr +=
@@ -1128,7 +1128,7 @@ static int linux_thread_extra_info(struct target *target,
/*LOG_INFO("lookup extra info for thread %" SCNx64, threadid);*/
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
char *pid = " PID: ";
char *pid_current = "*PID: ";
@@ -1176,7 +1176,7 @@ static int linux_gdb_t_packet(struct connection *connection,
struct threads *temp = linux_os->thread_list;
struct threads *prev = NULL;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
if (temp->status != 0) {
gdb_put_packet(connection, "OK", 2);
@@ -1205,7 +1205,7 @@ static int linux_gdb_t_packet(struct connection *connection,
retval = linux_task_update(target, 1);
struct threads *temp = linux_os->thread_list;
- while (temp != NULL) {
+ while (temp) {
if (temp->threadid == threadid) {
if (temp->status == 1) {
gdb_put_packet(connection, "OK", 2);
@@ -1231,20 +1231,20 @@ static int linux_gdb_h_packet(struct connection *connection,
struct current_thread *ct = linux_os->current_threads;
/* select to display the current thread of the selected target */
- while ((ct != NULL) && (ct->core_id != target->coreid))
+ while ((ct) && (ct->core_id != target->coreid))
ct = ct->next;
int64_t current_gdb_thread_rq;
if (linux_os->threads_lookup == 1) {
- if ((ct != NULL) && (ct->threadid == -1)) {
+ if ((ct) && (ct->threadid == -1)) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1))
+ while ((ct) && (ct->threadid == -1))
ct = ct->next;
}
- if (ct == NULL) {
+ if (!ct) {
/* no current thread can be identified
* any way with smp */
LOG_INFO("no current thread identified");
@@ -1253,7 +1253,7 @@ static int linux_gdb_h_packet(struct connection *connection,
struct threads t;
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1)) {
+ while ((ct) && (ct->threadid == -1)) {
t.base_addr = ct->TS;
get_name(target, &t);
LOG_INFO("name of unidentified thread %s",
@@ -1321,7 +1321,7 @@ static int linux_thread_packet(struct connection *connection, char const *packet
break;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
- if (linux_os->thread_list == NULL) {
+ if (!linux_os->thread_list) {
retval = linux_gdb_thread_packet(target,
connection,
packet,
@@ -1356,17 +1356,17 @@ static int linux_thread_packet(struct connection *connection, char const *packet
if (linux_os->threads_lookup == 1) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->core_id) != target->coreid)
+ while ((ct) && (ct->core_id) != target->coreid)
ct = ct->next;
- if ((ct != NULL) && (ct->threadid == -1)) {
+ if ((ct) && (ct->threadid == -1)) {
ct = linux_os->current_threads;
- while ((ct != NULL) && (ct->threadid == -1))
+ while ((ct) && (ct->threadid == -1))
ct = ct->next;
}
- if ((ct != NULL) && (ct->threadid !=
+ if ((ct) && (ct->threadid !=
target->rtos->current_threadid)
&& (target->rtos->current_threadid != -1))
LOG_WARNING("WARNING! current GDB thread do not match "
@@ -1478,7 +1478,7 @@ static char *linux_ps_command(struct target *target)
tmp += sprintf(tmp, "PID\t\tCPU\t\tASID\t\tNAME\n");
tmp += sprintf(tmp, "---\t\t---\t\t----\t\t----\n");
- while (temp != NULL) {
+ while (temp) {
if (temp->status) {
if (temp->context)
tmp +=
diff --git a/src/rtos/mqx.c b/src/rtos/mqx.c
index 9f59c6d..f6be35b 100644
--- a/src/rtos/mqx.c
+++ b/src/rtos/mqx.c
@@ -318,7 +318,7 @@ static int mqx_update_threads(
rtos->thread_count = task_queue_size;
rtos->current_thread = 0;
rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
- if (NULL == rtos->thread_details)
+ if (!rtos->thread_details)
return ERROR_FAIL;
/* loop over each task and setup thread details,
diff --git a/src/rtos/nuttx.c b/src/rtos/nuttx.c
index c525471..00fec7f 100644
--- a/src/rtos/nuttx.c
+++ b/src/rtos/nuttx.c
@@ -259,7 +259,7 @@ static int nuttx_update_threads(struct rtos *rtos)
uint32_t i;
uint8_t state;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for NuttX");
return -3;
}
diff --git a/src/rtos/riot.c b/src/rtos/riot.c
index 9165fe1..2316f17 100644
--- a/src/rtos/riot.c
+++ b/src/rtos/riot.c
@@ -121,15 +121,15 @@ static int riot_update_threads(struct rtos *rtos)
unsigned int tasks_found = 0;
const struct riot_params *param;
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return ERROR_FAIL;
param = (const struct riot_params *)rtos->rtos_specific_params;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("No symbols for RIOT");
return ERROR_FAIL;
}
@@ -202,7 +202,7 @@ static int riot_update_threads(struct rtos *rtos)
/* Allocate memory for thread description */
rtos->thread_details = calloc(thread_count, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("RIOT: out of memory");
return ERROR_FAIL;
}
@@ -321,13 +321,13 @@ static int riot_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
int retval;
const struct riot_params *param;
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
if (thread_id == 0)
return ERROR_FAIL;
- if (rtos->rtos_specific_params == NULL)
+ if (!rtos->rtos_specific_params)
return ERROR_FAIL;
param = (const struct riot_params *)rtos->rtos_specific_params;
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 7d96825..54e9926 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -172,7 +172,7 @@ void rtos_destroy(struct target *target)
int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size)
{
struct target *target = get_target_from_connection(connection);
- if (target->rtos == NULL)
+ if (!target->rtos)
return rtos_thread_packet(connection, packet, packet_size); /* thread not
*found*/
return target->rtos->gdb_thread_packet(connection, packet, packet_size);
@@ -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 != NULL) && (target->rtos->thread_details != NULL) &&
+ if ((target->rtos) && (target->rtos->thread_details != NULL) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
- if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details != NULL)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -329,17 +329,17 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
struct thread_detail *detail = &target->rtos->thread_details[found];
int str_size = 0;
- if (detail->thread_name_str != NULL)
+ if (detail->thread_name_str)
str_size += strlen(detail->thread_name_str);
- if (detail->extra_info_str != NULL)
+ if (detail->extra_info_str)
str_size += strlen(detail->extra_info_str);
char *tmp_str = calloc(str_size + 9, sizeof(char));
char *tmp_str_ptr = tmp_str;
- if (detail->thread_name_str != NULL)
+ if (detail->thread_name_str)
tmp_str_ptr += sprintf(tmp_str_ptr, "Name: %s", detail->thread_name_str);
- if (detail->extra_info_str != NULL) {
+ if (detail->extra_info_str) {
if (tmp_str_ptr != tmp_str)
tmp_str_ptr += sprintf(tmp_str_ptr, ", ");
tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->extra_info_str);
@@ -371,7 +371,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
return ERROR_OK;
} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
int i;
- if (target->rtos != NULL) {
+ if (target->rtos) {
if (target->rtos->thread_count == 0) {
gdb_put_packet(connection, "l", 1);
} else {
@@ -404,7 +404,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
* otherwise it gets incorrectly handled */
return GDB_THREAD_PACKET_NOT_CONSUMED;
} else if (strncmp(packet, "qC", 2) == 0) {
- if (target->rtos != NULL) {
+ if (target->rtos) {
char buffer[19];
int size;
size = snprintf(buffer, 19, "QC%016" PRIx64, target->rtos->current_thread);
@@ -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 != NULL) && (target->rtos->thread_details != NULL)) {
+ if ((target->rtos) && (target->rtos->thread_details != NULL)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -432,7 +432,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
return ERROR_OK;
} else if (packet[0] == 'H') { /* Set current thread ( 'c' for step and continue, 'g' for
* all other operations ) */
- if ((packet[1] == 'g') && (target->rtos != NULL)) {
+ if ((packet[1] == 'g') && (target->rtos)) {
threadid_t threadid;
sscanf(packet, "Hg%16" SCNx64, &threadid);
LOG_DEBUG("RTOS: GDB requested to set current thread to 0x%" PRIx64, threadid);
@@ -477,7 +477,7 @@ int rtos_get_gdb_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 != NULL) && (current_threadid != -1) &&
+ if ((target->rtos) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
(target->smp))) { /* in smp several current thread are possible */
@@ -529,7 +529,7 @@ int rtos_get_gdb_reg_list(struct connection *connection)
{
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
- if ((target->rtos != NULL) && (current_threadid != -1) &&
+ if ((target->rtos) && (current_threadid != -1) &&
(current_threadid != 0) &&
((current_threadid != target->rtos->current_thread) ||
(target->smp))) { /* in smp several current thread are possible */
@@ -563,7 +563,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 != NULL) &&
+ if ((target->rtos) &&
(target->rtos->type->set_reg != NULL) &&
(current_threadid != -1) &&
(current_threadid != 0)) {
@@ -606,7 +606,7 @@ int rtos_generic_stack_read(struct target *target,
#endif
int64_t new_stack_ptr;
- if (stacking->calculate_process_stack != NULL) {
+ if (stacking->calculate_process_stack) {
new_stack_ptr = stacking->calculate_process_stack(target,
stack_data, stacking, stack_ptr);
} else {
@@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target)
int rtos_update_threads(struct target *target)
{
- if ((target->rtos != NULL) && (target->rtos->type != NULL))
+ if ((target->rtos) && (target->rtos->type != NULL))
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 26b53a9..4cdf72d 100644
--- a/src/rtos/uCOS-III.c
+++ b/src/rtos/uCOS-III.c
@@ -278,7 +278,7 @@ static int ucos_iii_create(struct target *target)
for (size_t i = 0; i < ARRAY_SIZE(ucos_iii_params_list); i++)
if (strcmp(ucos_iii_params_list[i].target_name, target->type->name) == 0) {
params = malloc(sizeof(*params) + (UCOS_III_MAX_THREADS * sizeof(*params->threads)));
- if (params == NULL) {
+ if (!params) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
@@ -300,7 +300,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
struct ucos_iii_params *params = rtos->rtos_specific_params;
int retval;
- if (rtos->symbols == NULL) {
+ if (!rtos->symbols) {
LOG_ERROR("uCOS-III: symbol list not loaded");
return ERROR_FAIL;
}
@@ -326,7 +326,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
if (!rtos_running) {
rtos->thread_details = calloc(1, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
@@ -369,7 +369,7 @@ static int ucos_iii_update_threads(struct rtos *rtos)
}
rtos->thread_details = calloc(rtos->thread_count, sizeof(struct thread_detail));
- if (rtos->thread_details == NULL) {
+ if (!rtos->thread_details) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}
diff --git a/src/rtos/zephyr.c b/src/rtos/zephyr.c
index b594b2b..ef5ff58 100644
--- a/src/rtos/zephyr.c
+++ b/src/rtos/zephyr.c
@@ -745,14 +745,14 @@ static int zephyr_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
LOG_INFO("Getting thread %" PRId64 " reg list", thread_id);
- if (rtos == NULL)
+ if (!rtos)
return ERROR_FAIL;
if (thread_id == 0)
return ERROR_FAIL;
params = rtos->rtos_specific_params;
- if (params == NULL)
+ if (!params)
return ERROR_FAIL;
addr = thread_id + params->offsets[OFFSET_T_STACK_POINTER]