kernel: Compare pointers with NULL in while statements
Make while statement using pointers explicitly check whether the value is NULL or not. The C standard does not say that the null pointer is the same as the pointer to memory address 0 and because of this is a good practice always compare with the macro NULL. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
b3d9202704
commit
c806ac3d36
4 changed files with 8 additions and 7 deletions
|
@ -477,7 +477,7 @@ int _k_pipe_put_internal(struct k_pipe *pipe, struct k_pipe_async *async_desc,
|
|||
|
||||
struct k_thread *thread = (struct k_thread *)
|
||||
sys_dlist_get(&xfer_list);
|
||||
while (thread) {
|
||||
while (thread != NULL) {
|
||||
desc = (struct k_pipe_desc *)thread->base.swap_data;
|
||||
bytes_copied = pipe_xfer(desc->buffer, desc->bytes_to_xfer,
|
||||
data + num_bytes_written,
|
||||
|
@ -625,7 +625,7 @@ int _impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
|
||||
struct k_thread *thread = (struct k_thread *)
|
||||
sys_dlist_get(&xfer_list);
|
||||
while (thread && (num_bytes_read < bytes_to_read)) {
|
||||
while ((thread != NULL) && (num_bytes_read < bytes_to_read)) {
|
||||
desc = (struct k_pipe_desc *)thread->base.swap_data;
|
||||
bytes_copied = pipe_xfer(data + num_bytes_read,
|
||||
bytes_to_read - num_bytes_read,
|
||||
|
@ -665,7 +665,7 @@ int _impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
|
|||
* into the pipe's circular buffer.
|
||||
*/
|
||||
|
||||
while (thread) {
|
||||
while (thread != NULL) {
|
||||
desc = (struct k_pipe_desc *)thread->base.swap_data;
|
||||
bytes_copied = pipe_buffer_put(pipe, desc->buffer,
|
||||
desc->bytes_to_xfer);
|
||||
|
|
|
@ -237,7 +237,8 @@ void k_queue_append_list(struct k_queue *queue, void *head, void *tail)
|
|||
#if !defined(CONFIG_POLL)
|
||||
struct k_thread *thread;
|
||||
|
||||
while (head && ((thread = _unpend_first_thread(&queue->wait_q)))) {
|
||||
while ((head != NULL) &&
|
||||
(thread = _unpend_first_thread(&queue->wait_q))) {
|
||||
prepare_thread_to_run(thread, head);
|
||||
head = *(void **)head;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ static inline void handle_timeouts(s32_t ticks)
|
|||
* prohibited.
|
||||
*/
|
||||
|
||||
while (next) {
|
||||
while (next != NULL) {
|
||||
|
||||
/*
|
||||
* In the case where ticks number is greater than the first
|
||||
|
|
|
@ -162,8 +162,8 @@ void _thread_monitor_exit(struct k_thread *thread)
|
|||
struct k_thread *prev_thread;
|
||||
|
||||
prev_thread = _kernel.threads;
|
||||
while (prev_thread != NULL &&
|
||||
thread != prev_thread->next_thread) {
|
||||
while ((prev_thread != NULL) &&
|
||||
(thread != prev_thread->next_thread)) {
|
||||
prev_thread = prev_thread->next_thread;
|
||||
}
|
||||
if (prev_thread != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue