kernel: reduce `k_spin_unlock` calls using `if-else if-else` structure

Reduce `k_spin_unlock` calls in `k_obj_core_stats_xxx` functions by
consolidating error handling into an `if-else if-else` structure and
using a single return variable `rv`.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
1 file changed