syscall: Return bool in a boolean function

MISRA-C rule 14.4

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2018-11-21 17:46:38 -08:00 committed by Anas Nashif
commit 0bf21ca2a9
4 changed files with 14 additions and 10 deletions

View file

@ -24,6 +24,7 @@
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <stdbool.h>
#ifdef CONFIG_CPU_ARCV2
#include <arch/arc/v2/aux_regs.h>
@ -172,7 +173,7 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
return ret;
}
static inline int _arch_is_user_context(void)
static inline bool _arch_is_user_context(void)
{
u32_t status;
@ -182,7 +183,7 @@ static inline int _arch_is_user_context(void)
: "=r"(status)
: [status32] "i" (_ARC_V2_STATUS32));
return !(status & _ARC_V2_STATUS32_US);
return !(status & _ARC_V2_STATUS32_US) ? true : false;
}
#ifdef __cplusplus

View file

@ -24,6 +24,7 @@
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@ -153,19 +154,19 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
return ret;
}
static inline int _arch_is_user_context(void)
static inline bool _arch_is_user_context(void)
{
u32_t value;
/* check for handler mode */
__asm__ volatile("mrs %0, IPSR\n\t" : "=r"(value));
if (value) {
return 0;
return false;
}
/* if not handler mode, return mode information */
__asm__ volatile("mrs %0, CONTROL\n\t" : "=r"(value));
return value & 0x1;
return (value & 0x1) ? true : false;
}
#ifdef __cplusplus

View file

@ -23,6 +23,7 @@
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@ -151,7 +152,7 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
return ret;
}
static inline int _arch_is_user_context(void)
static inline bool _arch_is_user_context(void)
{
int cs;

View file

@ -10,6 +10,7 @@
#include <syscall_list.h>
#include <arch/syscall.h>
#include <stdbool.h>
#ifndef _ASMLANGUAGE
#include <zephyr/types.h>
@ -117,16 +118,16 @@ typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3,
/**
* Indicate whether we are currently running in user mode
*
* @return nonzero if the CPU is currently running with user permissions
* @return true if the CPU is currently running with user permissions
*/
static inline int _arch_is_user_context(void);
static inline bool _arch_is_user_context(void);
/**
* Indicate whether the CPU is currently in user mode
*
* @return nonzero if the CPU is currently running with user permissions
* @return true if the CPU is currently running with user permissions
*/
static inline int _is_user_context(void)
static inline bool _is_user_context(void)
{
return _arch_is_user_context();
}