diff options
| author | Randy Dunlap <rdunlap@xenotime.net> | 2006-09-27 04:50:55 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 11:26:18 -0400 |
| commit | ebba5f9fcb882306bef7175dee987342ec6fcf2f (patch) | |
| tree | a947175a24a3261ab3ffb5d9244e40939dd5495d | |
| parent | bd8e39f9e4c0960541c8c69e1f7cb321574d7c90 (diff) | |
[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: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | include/asm-arm/unistd.h | 3 | ||||
| -rw-r--r-- | include/asm-arm26/unistd.h | 3 | ||||
| -rw-r--r-- | include/asm-frv/unistd.h | 3 | ||||
| -rw-r--r-- | include/asm-h8300/unistd.h | 6 | ||||
| -rw-r--r-- | include/asm-i386/unistd.h | 5 | ||||
| -rw-r--r-- | include/asm-m32r/unistd.h | 5 | ||||
| -rw-r--r-- | include/asm-m68k/unistd.h | 5 | ||||
| -rw-r--r-- | include/asm-m68knommu/unistd.h | 5 | ||||
| -rw-r--r-- | include/asm-s390/unistd.h | 4 | ||||
| -rw-r--r-- | include/asm-sh/unistd.h | 7 | ||||
| -rw-r--r-- | include/asm-sh64/unistd.h | 6 | ||||
| -rw-r--r-- | include/asm-v850/unistd.h | 5 | ||||
| -rw-r--r-- | include/asm-x86_64/unistd.h | 5 | ||||
| -rw-r--r-- | include/linux/err.h | 4 |
14 files changed, 43 insertions, 23 deletions
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h index 1e891f860ef3..2ab4078334bf 100644 --- a/include/asm-arm/unistd.h +++ b/include/asm-arm/unistd.h | |||
| @@ -377,6 +377,7 @@ | |||
| 377 | #endif | 377 | #endif |
| 378 | 378 | ||
| 379 | #ifdef __KERNEL__ | 379 | #ifdef __KERNEL__ |
| 380 | #include <linux/err.h> | ||
| 380 | #include <linux/linkage.h> | 381 | #include <linux/linkage.h> |
| 381 | 382 | ||
| 382 | #define __sys2(x) #x | 383 | #define __sys2(x) #x |
| @@ -396,7 +397,7 @@ | |||
| 396 | 397 | ||
| 397 | #define __syscall_return(type, res) \ | 398 | #define __syscall_return(type, res) \ |
| 398 | do { \ | 399 | do { \ |
| 399 | if ((unsigned long)(res) >= (unsigned long)(-129)) { \ | 400 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 400 | errno = -(res); \ | 401 | errno = -(res); \ |
| 401 | res = -1; \ | 402 | res = -1; \ |
| 402 | } \ | 403 | } \ |
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h index 70eb6d91cfd0..c6d2436c9d34 100644 --- a/include/asm-arm26/unistd.h +++ b/include/asm-arm26/unistd.h | |||
| @@ -311,6 +311,7 @@ | |||
| 311 | #define __ARM_NR_usr26 (__ARM_NR_BASE+3) | 311 | #define __ARM_NR_usr26 (__ARM_NR_BASE+3) |
| 312 | 312 | ||
| 313 | #ifdef __KERNEL__ | 313 | #ifdef __KERNEL__ |
| 314 | #include <linux/err.h> | ||
| 314 | #include <linux/linkage.h> | 315 | #include <linux/linkage.h> |
| 315 | 316 | ||
| 316 | #define __sys2(x) #x | 317 | #define __sys2(x) #x |
| @@ -322,7 +323,7 @@ | |||
| 322 | 323 | ||
| 323 | #define __syscall_return(type, res) \ | 324 | #define __syscall_return(type, res) \ |
| 324 | do { \ | 325 | do { \ |
| 325 | if ((unsigned long)(res) >= (unsigned long)(-125)) { \ | 326 | if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \ |
| 326 | errno = -(res); \ | 327 | errno = -(res); \ |
| 327 | res = -1; \ | 328 | res = -1; \ |
| 328 | } \ | 329 | } \ |
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h index b80dbd839475..d104d1b91d39 100644 --- a/include/asm-frv/unistd.h +++ b/include/asm-frv/unistd.h | |||
| @@ -320,6 +320,7 @@ | |||
| 320 | #ifdef __KERNEL__ | 320 | #ifdef __KERNEL__ |
| 321 | 321 | ||
| 322 | #define NR_syscalls 310 | 322 | #define NR_syscalls 310 |
| 323 | #include <linux/err.h> | ||
| 323 | 324 | ||
| 324 | /* | 325 | /* |
| 325 | * process the return value of a syscall, consigning it to one of two possible fates | 326 | * process the return value of a syscall, consigning it to one of two possible fates |
| @@ -329,7 +330,7 @@ | |||
| 329 | #define __syscall_return(type, res) \ | 330 | #define __syscall_return(type, res) \ |
| 330 | do { \ | 331 | do { \ |
| 331 | unsigned long __sr2 = (res); \ | 332 | unsigned long __sr2 = (res); \ |
| 332 | if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) { \ | 333 | if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \ |
| 333 | errno = (-__sr2); \ | 334 | errno = (-__sr2); \ |
| 334 | __sr2 = ~0UL; \ | 335 | __sr2 = ~0UL; \ |
| 335 | } \ | 336 | } \ |
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h index 226dd596c2da..a2dd90462d80 100644 --- a/include/asm-h8300/unistd.h +++ b/include/asm-h8300/unistd.h | |||
| @@ -295,14 +295,14 @@ | |||
| 295 | #ifdef __KERNEL__ | 295 | #ifdef __KERNEL__ |
| 296 | 296 | ||
| 297 | #define NR_syscalls 289 | 297 | #define NR_syscalls 289 |
| 298 | #include <linux/err.h> | ||
| 298 | 299 | ||
| 299 | 300 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see | |
| 300 | /* user-visible error numbers are in the range -1 - -122: see | ||
| 301 | <asm-m68k/errno.h> */ | 301 | <asm-m68k/errno.h> */ |
| 302 | 302 | ||
| 303 | #define __syscall_return(type, res) \ | 303 | #define __syscall_return(type, res) \ |
| 304 | do { \ | 304 | do { \ |
| 305 | if ((unsigned long)(res) >= (unsigned long)(-125)) { \ | 305 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 306 | /* avoid using res which is declared to be in register d0; \ | 306 | /* avoid using res which is declared to be in register d0; \ |
| 307 | errno might expand to a function call and clobber it. */ \ | 307 | errno might expand to a function call and clobber it. */ \ |
| 308 | int __err = -(res); \ | 308 | int __err = -(res); \ |
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h index 565d0897b205..bd9987087adc 100644 --- a/include/asm-i386/unistd.h +++ b/include/asm-i386/unistd.h | |||
| @@ -328,14 +328,15 @@ | |||
| 328 | #ifdef __KERNEL__ | 328 | #ifdef __KERNEL__ |
| 329 | 329 | ||
| 330 | #define NR_syscalls 319 | 330 | #define NR_syscalls 319 |
| 331 | #include <linux/err.h> | ||
| 331 | 332 | ||
| 332 | /* | 333 | /* |
| 333 | * user-visible error numbers are in the range -1 - -128: see | 334 | * user-visible error numbers are in the range -1 - -MAX_ERRNO: see |
| 334 | * <asm-i386/errno.h> | 335 | * <asm-i386/errno.h> |
| 335 | */ | 336 | */ |
| 336 | #define __syscall_return(type, res) \ | 337 | #define __syscall_return(type, res) \ |
| 337 | do { \ | 338 | do { \ |
| 338 | if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \ | 339 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 339 | errno = -(res); \ | 340 | errno = -(res); \ |
| 340 | res = -1; \ | 341 | res = -1; \ |
| 341 | } \ | 342 | } \ |
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h index 89f376e6229f..5c6a9ac6cf1a 100644 --- a/include/asm-m32r/unistd.h +++ b/include/asm-m32r/unistd.h | |||
| @@ -296,8 +296,9 @@ | |||
| 296 | #ifdef __KERNEL__ | 296 | #ifdef __KERNEL__ |
| 297 | 297 | ||
| 298 | #define NR_syscalls 285 | 298 | #define NR_syscalls 285 |
| 299 | #include <linux/err.h> | ||
| 299 | 300 | ||
| 300 | /* user-visible error numbers are in the range -1 - -124: see | 301 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see |
| 301 | * <asm-m32r/errno.h> | 302 | * <asm-m32r/errno.h> |
| 302 | */ | 303 | */ |
| 303 | 304 | ||
| @@ -305,7 +306,7 @@ | |||
| 305 | 306 | ||
| 306 | #define __syscall_return(type, res) \ | 307 | #define __syscall_return(type, res) \ |
| 307 | do { \ | 308 | do { \ |
| 308 | if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \ | 309 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 309 | /* Avoid using "res" which is declared to be in register r0; \ | 310 | /* Avoid using "res" which is declared to be in register r0; \ |
| 310 | errno might expand to a function call and clobber it. */ \ | 311 | errno might expand to a function call and clobber it. */ \ |
| 311 | int __err = -(res); \ | 312 | int __err = -(res); \ |
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h index 7c0b6296b45c..751632b904db 100644 --- a/include/asm-m68k/unistd.h +++ b/include/asm-m68k/unistd.h | |||
| @@ -288,13 +288,14 @@ | |||
| 288 | #ifdef __KERNEL__ | 288 | #ifdef __KERNEL__ |
| 289 | 289 | ||
| 290 | #define NR_syscalls 282 | 290 | #define NR_syscalls 282 |
| 291 | #include <linux/err.h> | ||
| 291 | 292 | ||
| 292 | /* user-visible error numbers are in the range -1 - -124: see | 293 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see |
| 293 | <asm-m68k/errno.h> */ | 294 | <asm-m68k/errno.h> */ |
| 294 | 295 | ||
| 295 | #define __syscall_return(type, res) \ | 296 | #define __syscall_return(type, res) \ |
| 296 | do { \ | 297 | do { \ |
| 297 | if ((unsigned long)(res) >= (unsigned long)(-125)) { \ | 298 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 298 | /* avoid using res which is declared to be in register d0; \ | 299 | /* avoid using res which is declared to be in register d0; \ |
| 299 | errno might expand to a function call and clobber it. */ \ | 300 | errno might expand to a function call and clobber it. */ \ |
| 300 | int __err = -(res); \ | 301 | int __err = -(res); \ |
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h index 1b2abdf281e1..21fdc37c5c2c 100644 --- a/include/asm-m68knommu/unistd.h +++ b/include/asm-m68knommu/unistd.h | |||
| @@ -289,13 +289,14 @@ | |||
| 289 | #ifdef __KERNEL__ | 289 | #ifdef __KERNEL__ |
| 290 | 290 | ||
| 291 | #define NR_syscalls 282 | 291 | #define NR_syscalls 282 |
| 292 | #include <linux/err.h> | ||
| 292 | 293 | ||
| 293 | /* user-visible error numbers are in the range -1 - -122: see | 294 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: see |
| 294 | <asm-m68k/errno.h> */ | 295 | <asm-m68k/errno.h> */ |
| 295 | 296 | ||
| 296 | #define __syscall_return(type, res) \ | 297 | #define __syscall_return(type, res) \ |
| 297 | do { \ | 298 | do { \ |
| 298 | if ((unsigned long)(res) >= (unsigned long)(-125)) { \ | 299 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 299 | /* avoid using res which is declared to be in register d0; \ | 300 | /* avoid using res which is declared to be in register d0; \ |
| 300 | errno might expand to a function call and clobber it. */ \ | 301 | errno might expand to a function call and clobber it. */ \ |
| 301 | int __err = -(res); \ | 302 | int __err = -(res); \ |
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h index 02b942d85c37..d49c54cb5505 100644 --- a/include/asm-s390/unistd.h +++ b/include/asm-s390/unistd.h | |||
| @@ -342,9 +342,11 @@ | |||
| 342 | 342 | ||
| 343 | #ifdef __KERNEL__ | 343 | #ifdef __KERNEL__ |
| 344 | 344 | ||
| 345 | #include <linux/err.h> | ||
| 346 | |||
| 345 | #define __syscall_return(type, res) \ | 347 | #define __syscall_return(type, res) \ |
| 346 | do { \ | 348 | do { \ |
| 347 | if ((unsigned long)(res) >= (unsigned long)(-4095)) {\ | 349 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 348 | errno = -(res); \ | 350 | errno = -(res); \ |
| 349 | res = -1; \ | 351 | res = -1; \ |
| 350 | } \ | 352 | } \ |
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h index 76b5430cb458..da127d7901af 100644 --- a/include/asm-sh/unistd.h +++ b/include/asm-sh/unistd.h | |||
| @@ -306,11 +306,14 @@ | |||
| 306 | 306 | ||
| 307 | #ifdef __KERNEL__ | 307 | #ifdef __KERNEL__ |
| 308 | 308 | ||
| 309 | /* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */ | 309 | #include <linux/err.h> |
| 310 | |||
| 311 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: | ||
| 312 | * see <asm-sh/errno.h> */ | ||
| 310 | 313 | ||
| 311 | #define __syscall_return(type, res) \ | 314 | #define __syscall_return(type, res) \ |
| 312 | do { \ | 315 | do { \ |
| 313 | if ((unsigned long)(res) >= (unsigned long)(-124)) { \ | 316 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 314 | /* Avoid using "res" which is declared to be in register r0; \ | 317 | /* Avoid using "res" which is declared to be in register r0; \ |
| 315 | errno might expand to a function call and clobber it. */ \ | 318 | errno might expand to a function call and clobber it. */ \ |
| 316 | int __err = -(res); \ | 319 | int __err = -(res); \ |
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h index 9a1590fffc15..c113566bef33 100644 --- a/include/asm-sh64/unistd.h +++ b/include/asm-sh64/unistd.h | |||
| @@ -347,8 +347,10 @@ | |||
| 347 | #ifdef __KERNEL__ | 347 | #ifdef __KERNEL__ |
| 348 | 348 | ||
| 349 | #define NR_syscalls 321 | 349 | #define NR_syscalls 321 |
| 350 | #include <linux/err.h> | ||
| 350 | 351 | ||
| 351 | /* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */ | 352 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: |
| 353 | * see <asm-sh64/errno.h> */ | ||
| 352 | 354 | ||
| 353 | #define __syscall_return(type, res) \ | 355 | #define __syscall_return(type, res) \ |
| 354 | do { \ | 356 | do { \ |
| @@ -358,7 +360,7 @@ do { \ | |||
| 358 | ** life easier in the system call epilogue (see entry.S) \ | 360 | ** life easier in the system call epilogue (see entry.S) \ |
| 359 | */ \ | 361 | */ \ |
| 360 | register unsigned long __sr2 __asm__ ("r2") = res; \ | 362 | register unsigned long __sr2 __asm__ ("r2") = res; \ |
| 361 | if ((unsigned long)(res) >= (unsigned long)(-125)) { \ | 363 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 362 | errno = -(res); \ | 364 | errno = -(res); \ |
| 363 | __sr2 = -1; \ | 365 | __sr2 = -1; \ |
| 364 | } \ | 366 | } \ |
diff --git a/include/asm-v850/unistd.h b/include/asm-v850/unistd.h index bcb44bfe577a..552b7c873a57 100644 --- a/include/asm-v850/unistd.h +++ b/include/asm-v850/unistd.h | |||
| @@ -238,12 +238,13 @@ | |||
| 238 | #ifdef __KERNEL__ | 238 | #ifdef __KERNEL__ |
| 239 | 239 | ||
| 240 | #include <asm/clinkage.h> | 240 | #include <asm/clinkage.h> |
| 241 | #include <linux/err.h> | ||
| 241 | 242 | ||
| 242 | #define __syscall_return(type, res) \ | 243 | #define __syscall_return(type, res) \ |
| 243 | do { \ | 244 | do { \ |
| 244 | /* user-visible error numbers are in the range -1 - -124: \ | 245 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \ |
| 245 | see <asm-v850/errno.h> */ \ | 246 | see <asm-v850/errno.h> */ \ |
| 246 | if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \ | 247 | if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \ |
| 247 | errno = -(res); \ | 248 | errno = -(res); \ |
| 248 | res = -1; \ | 249 | res = -1; \ |
| 249 | } \ | 250 | } \ |
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h index eeb98c168e98..6137146516d3 100644 --- a/include/asm-x86_64/unistd.h +++ b/include/asm-x86_64/unistd.h | |||
| @@ -623,16 +623,17 @@ __SYSCALL(__NR_move_pages, sys_move_pages) | |||
| 623 | #ifdef __KERNEL__ | 623 | #ifdef __KERNEL__ |
| 624 | 624 | ||
| 625 | #define __NR_syscall_max __NR_move_pages | 625 | #define __NR_syscall_max __NR_move_pages |
| 626 | #include <linux/err.h> | ||
| 626 | 627 | ||
| 627 | #ifndef __NO_STUBS | 628 | #ifndef __NO_STUBS |
| 628 | 629 | ||
| 629 | /* user-visible error numbers are in the range -1 - -4095 */ | 630 | /* user-visible error numbers are in the range -1 - -MAX_ERRNO */ |
| 630 | 631 | ||
| 631 | #define __syscall_clobber "r11","rcx","memory" | 632 | #define __syscall_clobber "r11","rcx","memory" |
| 632 | 633 | ||
| 633 | #define __syscall_return(type, res) \ | 634 | #define __syscall_return(type, res) \ |
| 634 | do { \ | 635 | do { \ |
| 635 | if ((unsigned long)(res) >= (unsigned long)(-127)) { \ | 636 | if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
| 636 | errno = -(res); \ | 637 | errno = -(res); \ |
| 637 | res = -1; \ | 638 | res = -1; \ |
| 638 | } \ | 639 | } \ |
diff --git a/include/linux/err.h b/include/linux/err.h index cd3b367f7445..1ab1d44f8d3b 100644 --- a/include/linux/err.h +++ b/include/linux/err.h | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #define MAX_ERRNO 4095 | 16 | #define MAX_ERRNO 4095 |
| 17 | 17 | ||
| 18 | #ifndef __ASSEMBLY__ | ||
| 19 | |||
| 18 | #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) | 20 | #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) |
| 19 | 21 | ||
| 20 | static inline void *ERR_PTR(long error) | 22 | static inline void *ERR_PTR(long error) |
| @@ -32,4 +34,6 @@ static inline long IS_ERR(const void *ptr) | |||
| 32 | return IS_ERR_VALUE((unsigned long)ptr); | 34 | return IS_ERR_VALUE((unsigned long)ptr); |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 37 | #endif | ||
| 38 | |||
| 35 | #endif /* _LINUX_ERR_H */ | 39 | #endif /* _LINUX_ERR_H */ |
