I'm trying to do a full rebase (history clean) of the klibc kernel tree, and came across the following changesets between klibc 1.3.12 and .16: --- a/usr/klibc/arch/s390/syscall.c +++ b/usr/klibc/arch/s390/syscall.c @@ -11,6 +11,6 @@ long int __syscall_common(long int err) { if ((unsigned long)(err) < (unsigned long)(-125)) return err; - errno = err; + errno = -err; return -1; } diff --git a/usr/klibc/arch/s390x/syscall.c b/usr/klibc/arch/s390x/syscall.c index 0d6b27e..c0f17c4 100644 --- a/usr/klibc/arch/s390x/syscall.c +++ b/usr/klibc/arch/s390x/syscall.c @@ -11,6 +11,6 @@ long int __syscall_common(long int err) { if ((unsigned long)(err) < (unsigned long)(-125)) return err; - errno = -err; + errno = err; return -1; } The former is clearly right and the latter is clearly wrong. Should I change the s390x version to match s390? -hpa
On Mon, May 01, 2006 at 10:58:16AM -0700, H. Peter Anvin wrote:> I'm trying to do a full rebase (history clean) of the klibc kernel tree, and came across the following changesets between klibc 1.3.12 and .16: > > --- a/usr/klibc/arch/s390/syscall.c > +++ b/usr/klibc/arch/s390/syscall.c > @@ -11,6 +11,6 @@ long int __syscall_common(long int err) > { > if ((unsigned long)(err) < (unsigned long)(-125)) > return err; > - errno = err; > + errno = -err; > return -1; > } > diff --git a/usr/klibc/arch/s390x/syscall.c b/usr/klibc/arch/s390x/syscall.c > index 0d6b27e..c0f17c4 100644 > --- a/usr/klibc/arch/s390x/syscall.c > +++ b/usr/klibc/arch/s390x/syscall.c > @@ -11,6 +11,6 @@ long int __syscall_common(long int err) > { > if ((unsigned long)(err) < (unsigned long)(-125)) > return err; > - errno = -err; > + errno = err; > return -1; > } > > > The former is clearly right and the latter is clearly wrong. Should I change the s390x version to match s390?Looks like the right thing to do. Even though -125 seems to be wrong since we have already #define ENOTRECOVERABLE 131 /* State not recoverable */ Testing against -4095 is probably better.
Fix s390/s390x errno handling. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- usr/klibc/arch/s390/syscall.c | 2 +- usr/klibc/arch/s390x/syscall.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/klibc/arch/s390/syscall.c b/usr/klibc/arch/s390/syscall.c index 0d6b27e..baf473b 100644 --- a/usr/klibc/arch/s390/syscall.c +++ b/usr/klibc/arch/s390/syscall.c @@ -9,7 +9,7 @@ #include <errno.h> long int __syscall_common(long int err) { - if ((unsigned long)(err) < (unsigned long)(-125)) + if ((unsigned long)(err) < (unsigned long)(-4095)) return err; errno = -err; return -1; diff --git a/usr/klibc/arch/s390x/syscall.c b/usr/klibc/arch/s390x/syscall.c index c0f17c4..baf473b 100644 --- a/usr/klibc/arch/s390x/syscall.c +++ b/usr/klibc/arch/s390x/syscall.c @@ -9,8 +9,8 @@ #include <errno.h> long int __syscall_common(long int err) { - if ((unsigned long)(err) < (unsigned long)(-125)) + if ((unsigned long)(err) < (unsigned long)(-4095)) return err; - errno = err; + errno = -err; return -1; }