Skip to content

kernel: avoid using result of an assignment operator #72226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/condvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ int z_impl_k_condvar_broadcast(struct k_condvar *condvar)
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_condvar, broadcast, condvar);

/* wake up any threads that are waiting to write */
while ((pending_thread = z_unpend_first_thread(&condvar->wait_q)) !=
NULL) {
for (pending_thread = z_unpend_first_thread(&condvar->wait_q); pending_thread != NULL;
pending_thread = z_unpend_first_thread(&condvar->wait_q)) {
woken++;
arch_thread_return_value_set(pending_thread, 0);
z_ready_thread(pending_thread);
Expand Down
3 changes: 2 additions & 1 deletion kernel/msg_q.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ void z_impl_k_msgq_purge(struct k_msgq *msgq)
SYS_PORT_TRACING_OBJ_FUNC(k_msgq, purge, msgq);

/* wake up any threads that are waiting to write */
while ((pending_thread = z_unpend_first_thread(&msgq->wait_q)) != NULL) {
for (pending_thread = z_unpend_first_thread(&msgq->wait_q); pending_thread != NULL;
pending_thread = z_unpend_first_thread(&msgq->wait_q)) {
arch_thread_return_value_set(pending_thread, -ENOMSG);
z_ready_thread(pending_thread);
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ int z_unpend_all(_wait_q_t *wait_q)
int need_sched = 0;
struct k_thread *thread;

while ((thread = z_waitq_head(wait_q)) != NULL) {
for (thread = z_waitq_head(wait_q); thread != NULL; thread = z_waitq_head(wait_q)) {
z_unpend_thread(thread);
z_ready_thread(thread);
need_sched = 1;
Expand Down Expand Up @@ -1258,7 +1258,7 @@ static inline void unpend_all(_wait_q_t *wait_q)
{
struct k_thread *thread;

while ((thread = z_waitq_head(wait_q)) != NULL) {
for (thread = z_waitq_head(wait_q); thread != NULL; thread = z_waitq_head(wait_q)) {
unpend_thread_no_timeout(thread);
(void)z_abort_thread_timeout(thread);
arch_thread_return_value_set(thread, 0);
Expand Down
3 changes: 2 additions & 1 deletion kernel/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ void k_stack_init(struct k_stack *stack, stack_data_t *buffer,
{
z_waitq_init(&stack->wait_q);
stack->lock = (struct k_spinlock) {};
stack->next = stack->base = buffer;
stack->next = buffer;
stack->base = buffer;
stack->top = stack->base + num_entries;

SYS_PORT_TRACING_OBJ_INIT(k_stack, stack);
Expand Down
Loading