Skip to content

Commit d89ce8a

Browse files
Shawnshhwenlingz
authored andcommitted
hv: schedule: fix "Procedure has more than one exit point"
Misra C requires Function must have only 1 return entry. Fixed it by use "if ... else ..." format. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
1 parent 952943c commit d89ce8a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

hypervisor/common/schedule.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ void release_schedule_lock(uint16_t pcpu_id)
4141
uint16_t allocate_pcpu(void)
4242
{
4343
uint16_t i;
44+
uint16_t ret = INVALID_CPU_ID;
4445

4546
for (i = 0U; i < phys_cpu_num; i++) {
4647
if (bitmap_test_and_set_lock(i, &pcpu_used_bitmap) == 0) {
47-
return i;
48+
ret = i;
49+
break;
4850
}
4951
}
5052

51-
return INVALID_CPU_ID;
53+
return ret;
5254
}
5355

5456
void set_pcpu_used(uint16_t pcpu_id)
@@ -183,18 +185,18 @@ void schedule(void)
183185
if (prev == next) {
184186
release_schedule_lock(pcpu_id);
185187
return;
186-
}
187-
188-
prepare_switch(prev, next);
189-
release_schedule_lock(pcpu_id);
188+
} else {
189+
prepare_switch(prev, next);
190+
release_schedule_lock(pcpu_id);
190191

191-
if (next == NULL) {
192-
next = &idle;
193-
}
192+
if (next == NULL) {
193+
next = &idle;
194+
}
194195

195-
switch_to(next);
196+
switch_to(next);
196197

197-
ASSERT(false, "Shouldn't go here");
198+
ASSERT(false, "Shouldn't go here");
199+
}
198200
}
199201

200202
void switch_to_idle(run_thread_t idle_thread)

0 commit comments

Comments
 (0)