提交 ebba5f9f 编写于 作者: R Randy Dunlap 提交者: Linus Torvalds

[PATCH] consistently use MAX_ERRNO in __syscall_return

Consistently use MAX_ERRNO when checking for errors in __syscall_return().

[ralf@linux-mips.org: build fix]
Signed-off-by: NRandy Dunlap <rdunlap@xenotime.net>
Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 bd8e39f9
...@@ -377,6 +377,7 @@ ...@@ -377,6 +377,7 @@
#endif #endif
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/err.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#define __sys2(x) #x #define __sys2(x) #x
...@@ -396,7 +397,7 @@ ...@@ -396,7 +397,7 @@
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-129)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -311,6 +311,7 @@ ...@@ -311,6 +311,7 @@
#define __ARM_NR_usr26 (__ARM_NR_BASE+3) #define __ARM_NR_usr26 (__ARM_NR_BASE+3)
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/err.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#define __sys2(x) #x #define __sys2(x) #x
...@@ -322,7 +323,7 @@ ...@@ -322,7 +323,7 @@
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \ if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -320,6 +320,7 @@ ...@@ -320,6 +320,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 310 #define NR_syscalls 310
#include <linux/err.h>
/* /*
* process the return value of a syscall, consigning it to one of two possible fates * process the return value of a syscall, consigning it to one of two possible fates
...@@ -329,7 +330,7 @@ ...@@ -329,7 +330,7 @@
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
unsigned long __sr2 = (res); \ unsigned long __sr2 = (res); \
if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) { \ if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
errno = (-__sr2); \ errno = (-__sr2); \
__sr2 = ~0UL; \ __sr2 = ~0UL; \
} \ } \
......
...@@ -295,14 +295,14 @@ ...@@ -295,14 +295,14 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 289 #define NR_syscalls 289
#include <linux/err.h>
/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
/* user-visible error numbers are in the range -1 - -122: see
<asm-m68k/errno.h> */ <asm-m68k/errno.h> */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
/* avoid using res which is declared to be in register d0; \ /* avoid using res which is declared to be in register d0; \
errno might expand to a function call and clobber it. */ \ errno might expand to a function call and clobber it. */ \
int __err = -(res); \ int __err = -(res); \
......
...@@ -328,14 +328,15 @@ ...@@ -328,14 +328,15 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 319 #define NR_syscalls 319
#include <linux/err.h>
/* /*
* user-visible error numbers are in the range -1 - -128: see * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
* <asm-i386/errno.h> * <asm-i386/errno.h>
*/ */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -296,8 +296,9 @@ ...@@ -296,8 +296,9 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 285 #define NR_syscalls 285
#include <linux/err.h>
/* user-visible error numbers are in the range -1 - -124: see /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
* <asm-m32r/errno.h> * <asm-m32r/errno.h>
*/ */
...@@ -305,7 +306,7 @@ ...@@ -305,7 +306,7 @@
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
/* Avoid using "res" which is declared to be in register r0; \ /* Avoid using "res" which is declared to be in register r0; \
errno might expand to a function call and clobber it. */ \ errno might expand to a function call and clobber it. */ \
int __err = -(res); \ int __err = -(res); \
......
...@@ -288,13 +288,14 @@ ...@@ -288,13 +288,14 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 282 #define NR_syscalls 282
#include <linux/err.h>
/* user-visible error numbers are in the range -1 - -124: see /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
<asm-m68k/errno.h> */ <asm-m68k/errno.h> */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
/* avoid using res which is declared to be in register d0; \ /* avoid using res which is declared to be in register d0; \
errno might expand to a function call and clobber it. */ \ errno might expand to a function call and clobber it. */ \
int __err = -(res); \ int __err = -(res); \
......
...@@ -289,13 +289,14 @@ ...@@ -289,13 +289,14 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 282 #define NR_syscalls 282
#include <linux/err.h>
/* user-visible error numbers are in the range -1 - -122: see /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
<asm-m68k/errno.h> */ <asm-m68k/errno.h> */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
/* avoid using res which is declared to be in register d0; \ /* avoid using res which is declared to be in register d0; \
errno might expand to a function call and clobber it. */ \ errno might expand to a function call and clobber it. */ \
int __err = -(res); \ int __err = -(res); \
......
...@@ -342,9 +342,11 @@ ...@@ -342,9 +342,11 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/err.h>
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-4095)) {\ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -306,11 +306,14 @@ ...@@ -306,11 +306,14 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
/* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */ #include <linux/err.h>
/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
* see <asm-sh/errno.h> */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-124)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
/* Avoid using "res" which is declared to be in register r0; \ /* Avoid using "res" which is declared to be in register r0; \
errno might expand to a function call and clobber it. */ \ errno might expand to a function call and clobber it. */ \
int __err = -(res); \ int __err = -(res); \
......
...@@ -347,8 +347,10 @@ ...@@ -347,8 +347,10 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define NR_syscalls 321 #define NR_syscalls 321
#include <linux/err.h>
/* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */ /* user-visible error numbers are in the range -1 - -MAX_ERRNO:
* see <asm-sh64/errno.h> */
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
...@@ -358,7 +360,7 @@ do { \ ...@@ -358,7 +360,7 @@ do { \
** life easier in the system call epilogue (see entry.S) \ ** life easier in the system call epilogue (see entry.S) \
*/ \ */ \
register unsigned long __sr2 __asm__ ("r2") = res; \ register unsigned long __sr2 __asm__ ("r2") = res; \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \ errno = -(res); \
__sr2 = -1; \ __sr2 = -1; \
} \ } \
......
...@@ -238,12 +238,13 @@ ...@@ -238,12 +238,13 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <asm/clinkage.h> #include <asm/clinkage.h>
#include <linux/err.h>
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
/* user-visible error numbers are in the range -1 - -124: \ /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \
see <asm-v850/errno.h> */ \ see <asm-v850/errno.h> */ \
if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \ if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -623,16 +623,17 @@ __SYSCALL(__NR_move_pages, sys_move_pages) ...@@ -623,16 +623,17 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
#ifdef __KERNEL__ #ifdef __KERNEL__
#define __NR_syscall_max __NR_move_pages #define __NR_syscall_max __NR_move_pages
#include <linux/err.h>
#ifndef __NO_STUBS #ifndef __NO_STUBS
/* user-visible error numbers are in the range -1 - -4095 */ /* user-visible error numbers are in the range -1 - -MAX_ERRNO */
#define __syscall_clobber "r11","rcx","memory" #define __syscall_clobber "r11","rcx","memory"
#define __syscall_return(type, res) \ #define __syscall_return(type, res) \
do { \ do { \
if ((unsigned long)(res) >= (unsigned long)(-127)) { \ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \ errno = -(res); \
res = -1; \ res = -1; \
} \ } \
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
#define MAX_ERRNO 4095 #define MAX_ERRNO 4095
#ifndef __ASSEMBLY__
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
static inline void *ERR_PTR(long error) static inline void *ERR_PTR(long error)
...@@ -32,4 +34,6 @@ static inline long IS_ERR(const void *ptr) ...@@ -32,4 +34,6 @@ static inline long IS_ERR(const void *ptr)
return IS_ERR_VALUE((unsigned long)ptr); return IS_ERR_VALUE((unsigned long)ptr);
} }
#endif
#endif /* _LINUX_ERR_H */ #endif /* _LINUX_ERR_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册