Browse Source

kernel: thread: add default case, remove unused break

According to the Zephyr Coding Guideline all switch statements
shall be well-formed. Add a default case with break and comment
to avoid static analysis tool to raise a violation that there is no
default case.
Also, I think, in all cases above no need to use "break",
because they already are using "return".

Found as a coding guideline violation (MISRA R16.1) by static
coding scanning tool.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
pull/35226/head
Maksim Masalski 4 years ago committed by Kumar Gala
parent
commit
e9600a75fc
  1. 11
      kernel/thread.c

11
kernel/thread.c

@ -267,27 +267,24 @@ const char *k_thread_state_str(k_tid_t thread_id) @@ -267,27 +267,24 @@ const char *k_thread_state_str(k_tid_t thread_id)
switch (thread_id->base.thread_state) {
case 0:
return "";
break;
case _THREAD_DUMMY:
return "dummy";
break;
case _THREAD_PENDING:
return "pending";
break;
case _THREAD_PRESTART:
return "prestart";
break;
case _THREAD_DEAD:
return "dead";
break;
case _THREAD_SUSPENDED:
return "suspended";
break;
case _THREAD_ABORTING:
return "aborting";
break;
case _THREAD_QUEUED:
return "queued";
default:
/* Add a break, some day when another case gets added at the end,
* this bit of defensive programming will be useful
*/
break;
}
return "unknown";

Loading…
Cancel
Save