From: "Randy.Dunlap" <rdunlap@xenotime.net>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: ralf@linux-mips.org, akpm@osdl.org,
erik_frederiksen@pmc-sierra.com, linux-kernel@vger.kernel.org
Subject: [PATCH] consistently use MAX_ERRNO in __syscall_return
Date: Sun, 2 Jul 2006 11:27:22 -0700 [thread overview]
Message-ID: <20060702112722.74b5adff.rdunlap@xenotime.net> (raw)
In-Reply-To: <44A6F5E3.8000300@zytor.com>
On Sat, 01 Jul 2006 15:23:31 -0700 H. Peter Anvin wrote:
> > Are changes also needed in asm-*/unistd.h::syscall_return() macros?
> > or is syscall_return() just not used?
> >
> > e.g.,
> > arm26 uses -125 to detect error
> > arm uses -129 to detect error
> > frv uses -4095 to detect error
> > i386 uses -129
> > h8300, m32r, s390, sh64, v850 use -125
> > m68k[nommu] uses -125
> > sh uses -124
> > x86_64 uses -127
> >
>
> ... and they're pretty much all wrong (in some cases, they're actually
> less than actual errno values on that architecture!)
>
> It pretty much works because they're not used. They should either be
> fixed or removed.
From: Randy Dunlap <rdunlap@xenotime.net>
Consistently use MAX_ERRNO when checking for errors
in __syscall_return().
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
---
include/asm-arm/unistd.h | 3 ++-
include/asm-arm26/unistd.h | 3 ++-
include/asm-frv/unistd.h | 3 ++-
include/asm-h8300/unistd.h | 6 +++---
include/asm-i386/unistd.h | 5 +++--
include/asm-m32r/unistd.h | 5 +++--
include/asm-m68k/unistd.h | 5 +++--
include/asm-m68knommu/unistd.h | 5 +++--
include/asm-s390/unistd.h | 4 +++-
include/asm-sh/unistd.h | 7 +++++--
include/asm-sh64/unistd.h | 6 ++++--
include/asm-v850/unistd.h | 5 +++--
include/asm-x86_64/unistd.h | 5 +++--
13 files changed, 39 insertions(+), 23 deletions(-)
--- linux-2617-g20.orig/include/asm-arm/unistd.h
+++ linux-2617-g20/include/asm-arm/unistd.h
@@ -377,6 +377,7 @@
#endif
#ifdef __KERNEL__
+#include <linux/err.h>
#include <linux/linkage.h>
#define __sys2(x) #x
@@ -396,7 +397,7 @@
#define __syscall_return(type, res) \
do { \
- if ((unsigned long)(res) >= (unsigned long)(-129)) { \
+ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \
res = -1; \
} \
--- linux-2617-g20.orig/include/asm-arm26/unistd.h
+++ linux-2617-g20/include/asm-arm26/unistd.h
@@ -311,6 +311,7 @@
#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
#ifdef __KERNEL__
+#include <linux/err.h>
#include <linux/linkage.h>
#define __sys2(x) #x
@@ -322,7 +323,7 @@
#define __syscall_return(type, res) \
do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
errno = -(res); \
res = -1; \
} \
--- linux-2617-g20.orig/include/asm-frv/unistd.h
+++ linux-2617-g20/include/asm-frv/unistd.h
@@ -320,6 +320,7 @@
#ifdef __KERNEL__
#define NR_syscalls 310
+#include <linux/err.h>
/*
* process the return value of a syscall, consigning it to one of two possible fates
@@ -329,7 +330,7 @@
#define __syscall_return(type, res) \
do { \
unsigned long __sr2 = (res); \
- if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) { \
+ if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
errno = (-__sr2); \
__sr2 = ~0UL; \
} \
--- linux-2617-g20.orig/include/asm-h8300/unistd.h
+++ linux-2617-g20/include/asm-h8300/unistd.h
@@ -295,14 +295,14 @@
#ifdef __KERNEL__
#define NR_syscalls 289
+#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> */
#define __syscall_return(type, res) \
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; \
errno might expand to a function call and clobber it. */ \
int __err = -(res); \
--- linux-2617-g20.orig/include/asm-i386/unistd.h
+++ linux-2617-g20/include/asm-i386/unistd.h
@@ -327,14 +327,15 @@
#ifdef __KERNEL__
#define NR_syscalls 318
+#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>
*/
#define __syscall_return(type, res) \
do { \
- if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \
+ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \
res = -1; \
} \
--- linux-2617-g20.orig/include/asm-m32r/unistd.h
+++ linux-2617-g20/include/asm-m32r/unistd.h
@@ -298,14 +298,15 @@
#ifdef __KERNEL__
#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>
*/
#define __syscall_return(type, res) \
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; \
errno might expand to a function call and clobber it. */ \
int __err = -(res); \
--- linux-2617-g20.orig/include/asm-m68k/unistd.h
+++ linux-2617-g20/include/asm-m68k/unistd.h
@@ -288,13 +288,14 @@
#ifdef __KERNEL__
#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> */
#define __syscall_return(type, res) \
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; \
errno might expand to a function call and clobber it. */ \
int __err = -(res); \
--- linux-2617-g20.orig/include/asm-m68knommu/unistd.h
+++ linux-2617-g20/include/asm-m68knommu/unistd.h
@@ -289,13 +289,14 @@
#ifdef __KERNEL__
#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> */
#define __syscall_return(type, res) \
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; \
errno might expand to a function call and clobber it. */ \
int __err = -(res); \
--- linux-2617-g20.orig/include/asm-s390/unistd.h
+++ linux-2617-g20/include/asm-s390/unistd.h
@@ -394,9 +394,11 @@
#ifdef __KERNEL__
+#include <linux/err.h>
+
#define __syscall_return(type, res) \
do { \
- if ((unsigned long)(res) >= (unsigned long)(-4095)) {\
+ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \
res = -1; \
} \
--- linux-2617-g20.orig/include/asm-sh64/unistd.h
+++ linux-2617-g20/include/asm-sh64/unistd.h
@@ -347,8 +347,10 @@
#ifdef __KERNEL__
#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) \
do { \
@@ -358,7 +360,7 @@ do { \
** life easier in the system call epilogue (see entry.S) \
*/ \
register unsigned long __sr2 __asm__ ("r2") = res; \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \
__sr2 = -1; \
} \
--- linux-2617-g20.orig/include/asm-sh/unistd.h
+++ linux-2617-g20/include/asm-sh/unistd.h
@@ -306,11 +306,14 @@
#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) \
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; \
errno might expand to a function call and clobber it. */ \
int __err = -(res); \
--- linux-2617-g20.orig/include/asm-v850/unistd.h
+++ linux-2617-g20/include/asm-v850/unistd.h
@@ -238,12 +238,13 @@
#ifdef __KERNEL__
#include <asm/clinkage.h>
+#include <linux/err.h>
#define __syscall_return(type, res) \
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> */ \
- if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \
+ if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
errno = -(res); \
res = -1; \
} \
--- linux-2617-g20.orig/include/asm-x86_64/unistd.h
+++ linux-2617-g20/include/asm-x86_64/unistd.h
@@ -623,16 +623,17 @@ __SYSCALL(__NR_move_pages, sys_move_page
#ifdef __KERNEL__
#define __NR_syscall_max __NR_move_pages
+#include <linux/err.h>
#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_return(type, res) \
do { \
- if ((unsigned long)(res) >= (unsigned long)(-127)) { \
+ if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
errno = -(res); \
res = -1; \
} \
---
next prev parent reply other threads:[~2006-07-02 18:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-28 20:57 IS_ERR Threshold Value Erik Frederiksen
2006-06-28 21:08 ` Randy.Dunlap
2006-06-28 22:39 ` H. Peter Anvin
2006-06-29 18:10 ` Ralf Baechle
2006-07-01 18:44 ` Randy.Dunlap
2006-07-01 22:23 ` H. Peter Anvin
2006-07-02 16:15 ` Ralf Baechle
2006-07-02 17:40 ` H. Peter Anvin
2006-07-02 18:22 ` Randy.Dunlap
2006-07-02 18:27 ` Randy.Dunlap [this message]
2006-07-03 7:39 ` [PATCH] consistently use MAX_ERRNO in __syscall_return Andrew Morton
2006-07-03 15:03 ` H. Peter Anvin
2006-07-03 15:42 ` Randy.Dunlap
2006-07-03 16:09 ` H. Peter Anvin
2006-10-16 19:31 ` IS_ERR Threshold Value Andreas Mohr
2006-10-18 12:47 ` Jan Engelhardt
2006-06-28 22:41 ` Nathan Scott
2006-06-28 23:13 ` Erik Frederiksen
2006-06-28 23:22 ` Randy.Dunlap
2006-06-28 23:23 ` Nathan Scott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060702112722.74b5adff.rdunlap@xenotime.net \
--to=rdunlap@xenotime.net \
--cc=akpm@osdl.org \
--cc=erik_frederiksen@pmc-sierra.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®