Skip to content

Commit 20b5542

Browse files
DeHessaescolar
authored andcommitted
coding guidelines: comply with MISRA Rule 13.4
avoid the direct use of assignment expression values for conditions Signed-off-by: Hess Nathan <nhess@baumer.com>
1 parent 51bcc5d commit 20b5542

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

kernel/condvar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ int z_impl_k_condvar_broadcast(struct k_condvar *condvar)
8484
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_condvar, broadcast, condvar);
8585

8686
/* wake up any threads that are waiting to write */
87-
while ((pending_thread = z_unpend_first_thread(&condvar->wait_q)) !=
88-
NULL) {
87+
for (pending_thread = z_unpend_first_thread(&condvar->wait_q); pending_thread != NULL;
88+
pending_thread = z_unpend_first_thread(&condvar->wait_q)) {
8989
woken++;
9090
arch_thread_return_value_set(pending_thread, 0);
9191
z_ready_thread(pending_thread);

kernel/msg_q.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ void z_impl_k_msgq_purge(struct k_msgq *msgq)
383383
SYS_PORT_TRACING_OBJ_FUNC(k_msgq, purge, msgq);
384384

385385
/* wake up any threads that are waiting to write */
386-
while ((pending_thread = z_unpend_first_thread(&msgq->wait_q)) != NULL) {
386+
for (pending_thread = z_unpend_first_thread(&msgq->wait_q); pending_thread != NULL;
387+
pending_thread = z_unpend_first_thread(&msgq->wait_q)) {
387388
arch_thread_return_value_set(pending_thread, -ENOMSG);
388389
z_ready_thread(pending_thread);
389390
}

kernel/sched.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ int z_unpend_all(_wait_q_t *wait_q)
958958
int need_sched = 0;
959959
struct k_thread *thread;
960960

961-
while ((thread = z_waitq_head(wait_q)) != NULL) {
961+
for (thread = z_waitq_head(wait_q); thread != NULL; thread = z_waitq_head(wait_q)) {
962962
z_unpend_thread(thread);
963963
z_ready_thread(thread);
964964
need_sched = 1;
@@ -1269,7 +1269,7 @@ static inline void unpend_all(_wait_q_t *wait_q)
12691269
{
12701270
struct k_thread *thread;
12711271

1272-
while ((thread = z_waitq_head(wait_q)) != NULL) {
1272+
for (thread = z_waitq_head(wait_q); thread != NULL; thread = z_waitq_head(wait_q)) {
12731273
unpend_thread_no_timeout(thread);
12741274
(void)z_abort_thread_timeout(thread);
12751275
arch_thread_return_value_set(thread, 0);

kernel/stack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ void k_stack_init(struct k_stack *stack, stack_data_t *buffer,
2929
{
3030
z_waitq_init(&stack->wait_q);
3131
stack->lock = (struct k_spinlock) {};
32-
stack->next = stack->base = buffer;
32+
stack->next = buffer;
33+
stack->base = buffer;
3334
stack->top = stack->base + num_entries;
3435

3536
SYS_PORT_TRACING_OBJ_INIT(k_stack, stack);

0 commit comments

Comments
 (0)