Skip to content

Commit 0bf21ca

Browse files
Flavio Ceolinnashif
authored andcommitted
syscall: Return bool in a boolean function
MISRA-C rule 14.4 Signed-off-by: Flavio Ceolin <[email protected]>
1 parent d0a2c4d commit 0bf21ca

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

include/arch/arc/syscall.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#ifndef _ASMLANGUAGE
2525

2626
#include <zephyr/types.h>
27+
#include <stdbool.h>
2728

2829
#ifdef CONFIG_CPU_ARCV2
2930
#include <arch/arc/v2/aux_regs.h>
@@ -172,7 +173,7 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
172173
return ret;
173174
}
174175

175-
static inline int _arch_is_user_context(void)
176+
static inline bool _arch_is_user_context(void)
176177
{
177178
u32_t status;
178179

@@ -182,7 +183,7 @@ static inline int _arch_is_user_context(void)
182183
: "=r"(status)
183184
: [status32] "i" (_ARC_V2_STATUS32));
184185

185-
return !(status & _ARC_V2_STATUS32_US);
186+
return !(status & _ARC_V2_STATUS32_US) ? true : false;
186187
}
187188

188189
#ifdef __cplusplus

include/arch/arm/syscall.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#ifndef _ASMLANGUAGE
2525

2626
#include <zephyr/types.h>
27+
#include <stdbool.h>
2728

2829
#ifdef __cplusplus
2930
extern "C" {
@@ -153,19 +154,19 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
153154
return ret;
154155
}
155156

156-
static inline int _arch_is_user_context(void)
157+
static inline bool _arch_is_user_context(void)
157158
{
158159
u32_t value;
159160

160161
/* check for handler mode */
161162
__asm__ volatile("mrs %0, IPSR\n\t" : "=r"(value));
162163
if (value) {
163-
return 0;
164+
return false;
164165
}
165166

166167
/* if not handler mode, return mode information */
167168
__asm__ volatile("mrs %0, CONTROL\n\t" : "=r"(value));
168-
return value & 0x1;
169+
return (value & 0x1) ? true : false;
169170
}
170171

171172
#ifdef __cplusplus

include/arch/x86/syscall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#ifndef _ASMLANGUAGE
2424

2525
#include <zephyr/types.h>
26+
#include <stdbool.h>
2627

2728
#ifdef __cplusplus
2829
extern "C" {
@@ -151,7 +152,7 @@ static inline u32_t _arch_syscall_invoke0(u32_t call_id)
151152
return ret;
152153
}
153154

154-
static inline int _arch_is_user_context(void)
155+
static inline bool _arch_is_user_context(void)
155156
{
156157
int cs;
157158

include/syscall.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <syscall_list.h>
1212
#include <arch/syscall.h>
13+
#include <stdbool.h>
1314

1415
#ifndef _ASMLANGUAGE
1516
#include <zephyr/types.h>
@@ -117,16 +118,16 @@ typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3,
117118
/**
118119
* Indicate whether we are currently running in user mode
119120
*
120-
* @return nonzero if the CPU is currently running with user permissions
121+
* @return true if the CPU is currently running with user permissions
121122
*/
122-
static inline int _arch_is_user_context(void);
123+
static inline bool _arch_is_user_context(void);
123124

124125
/**
125126
* Indicate whether the CPU is currently in user mode
126127
*
127-
* @return nonzero if the CPU is currently running with user permissions
128+
* @return true if the CPU is currently running with user permissions
128129
*/
129-
static inline int _is_user_context(void)
130+
static inline bool _is_user_context(void)
130131
{
131132
return _arch_is_user_context();
132133
}

0 commit comments

Comments
 (0)