Skip to content

Commit

Permalink
coding guidelines: comply with MISRA C:2012 Rule 2.2
Browse files Browse the repository at this point in the history
- avoided dead stores

Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
  • Loading branch information
Abramo-Bagnara authored and nashif committed Apr 7, 2022
1 parent 77efdc7 commit 88608b2
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 17 deletions.
3 changes: 1 addition & 2 deletions arch/x86/core/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void find_rsdp(void)
{
uint8_t *bda_seg, *zero_page_base;
uint64_t *search;
uintptr_t search_phys, rsdp_phys = 0U;
uintptr_t search_phys, rsdp_phys;
size_t search_length, rsdp_length;

if (is_rsdp_searched) {
Expand Down Expand Up @@ -80,7 +80,6 @@ static void find_rsdp(void)
search_length = 128 * 1024;
z_phys_map((uint8_t **)&search, search_phys, search_length, 0);

rsdp_phys = 0U;
for (size_t i = 0; i < ((128*1024)/8); i++) {
if (search[i] == ACPI_RSDP_SIGNATURE) {
rsdp_phys = search_phys + (i * 8);
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/zefi/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static size_t vpf(struct _pfr *r, const char *f, va_list ap)

static inline int snprintf(char *buf, size_t len, const char *f, ...)
{
int ret = 0;
int ret;
struct _pfr r = { .buf = buf, .len = len };

CALL_VPF(&r);
Expand All @@ -163,7 +163,7 @@ static inline int snprintf(char *buf, size_t len, const char *f, ...)

static inline int sprintf(char *buf, const char *f, ...)
{
int ret = 0;
int ret;
struct _pfr r = { .buf = buf, .len = 0x7fffffff };

CALL_VPF(&r);
Expand All @@ -172,7 +172,7 @@ static inline int sprintf(char *buf, const char *f, ...)

static inline int printf(const char *f, ...)
{
int ret = 0;
int ret;
struct _pfr r = {0};

CALL_VPF(&r);
Expand Down
2 changes: 1 addition & 1 deletion kernel/mem_slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ SYS_INIT(init_mem_slab_module, PRE_KERNEL_1,
int k_mem_slab_init(struct k_mem_slab *slab, void *buffer,
size_t block_size, uint32_t num_blocks)
{
int rc = 0;
int rc;

slab->num_blocks = num_blocks;
slab->block_size = block_size;
Expand Down
2 changes: 1 addition & 1 deletion kernel/pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ int z_impl_k_pipe_get(struct k_pipe *pipe, void *data, size_t bytes_to_read,
struct k_thread *writer;
struct k_pipe_desc *desc;
sys_dlist_t xfer_list;
size_t num_bytes_read = 0;
size_t num_bytes_read;
size_t bytes_copied;

SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_pipe, get, pipe, timeout);
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ void z_impl_k_thread_abort(k_tid_t thread)
int z_impl_k_thread_join(struct k_thread *thread, k_timeout_t timeout)
{
k_spinlock_key_t key = k_spin_lock(&sched_spinlock);
int ret = 0;
int ret;

SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_thread, join, thread, timeout);

Expand Down
2 changes: 1 addition & 1 deletion kernel/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static inline void z_vrfy_k_sem_give(struct k_sem *sem)

int z_impl_k_sem_take(struct k_sem *sem, k_timeout_t timeout)
{
int ret = 0;
int ret;

__ASSERT(((arch_is_in_isr() == false) ||
K_TIMEOUT_EQ(timeout, K_NO_WAIT)), "");
Expand Down
4 changes: 2 additions & 2 deletions kernel/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static inline int queue_submit_locked(struct k_work_q *queue,
return -EINVAL;
}

int ret = -EBUSY;
int ret;
bool chained = (_current == &queue->thread) && !k_is_in_isr();
bool draining = flag_test(&queue->flags, K_WORK_QUEUE_DRAIN_BIT);
bool plugged = flag_test(&queue->flags, K_WORK_QUEUE_PLUGGED_BIT);
Expand Down Expand Up @@ -975,7 +975,7 @@ int k_work_reschedule_for_queue(struct k_work_q *queue,

SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_work, reschedule_for_queue, queue, dwork, delay);

int ret = 0;
int ret;
k_spinlock_key_t key = k_spin_lock(&lock);

/* Remove any active scheduling. */
Expand Down
2 changes: 1 addition & 1 deletion lib/os/cbprintf_complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
* * the converted value
*/
size_t nj_len = (size_t)(bpe - bps);
int pad_len = 0;
int pad_len;

if (sign != '\0') {
nj_len += 1U;
Expand Down
3 changes: 1 addition & 2 deletions lib/os/onoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static void process_event(struct onoff_manager *mgr,
{
sys_slist_t clients;
uint16_t state = mgr->flags & ONOFF_STATE_MASK;
int res = 0;
int res;
bool processing = ((mgr->flags & ONOFF_FLAG_PROCESSING) != 0);

__ASSERT_NO_MSG(evt != EVT_NOP);
Expand Down Expand Up @@ -396,7 +396,6 @@ static void process_event(struct onoff_manager *mgr,

key = k_spin_lock(&mgr->lock);
mgr->flags &= (uint16_t)~ONOFF_FLAG_PROCESSING;
state = mgr->flags & ONOFF_STATE_MASK;
}

/* Process deferred events. Completion takes priority
Expand Down
5 changes: 2 additions & 3 deletions lib/os/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int sys_sem_give(struct sys_sem *sem)

int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout)
{
int ret = 0;
int ret;
atomic_t old_value;

do {
Expand Down Expand Up @@ -122,9 +122,8 @@ int sys_sem_give(struct sys_sem *sem)

int sys_sem_take(struct sys_sem *sem, k_timeout_t timeout)
{
int ret_value = 0;
int ret_value = k_sem_take(&sem->kernel_sem, timeout);

ret_value = k_sem_take(&sem->kernel_sem, timeout);
if ((ret_value == -EAGAIN) || (ret_value == -EBUSY)) {
ret_value = -ETIMEDOUT;
}
Expand Down

0 comments on commit 88608b2

Please sign in to comment.