From 4127cc13bfb11ccc2371bf59700138c113d12271 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Thu, 9 May 2019 08:38:18 +0800 Subject: [Kernel] Move the ++/-- operator outside of condition. --- src/cpu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cpu.c b/src/cpu.c index 3e2d65dfb9..fe3ba21bb0 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -42,12 +42,16 @@ rt_base_t rt_cpus_lock(void) pcpu = rt_cpu_self(); if (pcpu->current_thread != RT_NULL) { - if (pcpu->current_thread->cpus_lock_nest++ == 0) + register rt_uint16_t lock_nest = pcpu->current_thread->cpus_lock_nest; + + pcpu->current_thread->cpus_lock_nest++; + if (lock_nest == 0) { pcpu->current_thread->scheduler_lock_nest++; rt_hw_spin_lock(&_cpus_lock); } } + return level; } RTM_EXPORT(rt_cpus_lock); @@ -61,7 +65,9 @@ void rt_cpus_unlock(rt_base_t level) if (pcpu->current_thread != RT_NULL) { - if (--pcpu->current_thread->cpus_lock_nest == 0) + pcpu->current_thread->cpus_lock_nest--; + + if (pcpu->current_thread->cpus_lock_nest == 0) { pcpu->current_thread->scheduler_lock_nest--; rt_hw_spin_unlock(&_cpus_lock); -- cgit v1.3.1 From 43c1236ec9fd0d8530714370b7a664efd6d9bf3a Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Thu, 9 May 2019 08:57:24 +0800 Subject: [Kernel] code cleanup for indentation. --- src/ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 74faf6ac7e..0df4f05f23 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -753,8 +753,8 @@ __again: if (thread->error != RT_EOK) { - /* interrupt by signal, try it again */ - if (thread->error == -RT_EINTR) goto __again; + /* interrupt by signal, try it again */ + if (thread->error == -RT_EINTR) goto __again; /* return error */ return thread->error; -- cgit v1.3.1