diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-04-14 15:27:25 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-04-14 15:27:25 +0000 |
commit | ff5707a42600f393c5303517e68ff79eecabcc6d (patch) | |
tree | 995e7557d4a454639c392ced77199f54d84bc25c /libc/sysdeps/unix/sysv | |
parent | a9627899a6ea28893ca8b1a2b475aecc58d6f223 (diff) | |
download | eglibc2-ff5707a42600f393c5303517e68ff79eecabcc6d.tar.gz |
Merge changes between r10202 and r10245 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@10246 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/unix/sysv')
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/getlogin_r.c | 16 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/i386/fallocate.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/i386/fallocate64.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c | 64 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c | 62 |
5 files changed, 89 insertions, 69 deletions
diff --git a/libc/sysdeps/unix/sysv/linux/getlogin_r.c b/libc/sysdeps/unix/sysv/linux/getlogin_r.c index d07846ccb..d9c66fe25 100644 --- a/libc/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/libc/sysdeps/unix/sysv/linux/getlogin_r.c @@ -37,13 +37,20 @@ __getlogin_r_loginuid (name, namesize) if (fd == -1) return 1; - ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, name, namesize)); + /* We are reading a 32-bit number. 12 bytes are enough for the text + representation. If not, something is wrong. */ + char uidbuf[12]; + ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, uidbuf, + sizeof (uidbuf))); close_not_cancel_no_status (fd); uid_t uid; char *endp; if (n <= 0 - || (uid = strtoul (name, &endp, 10), endp == name || *endp != '\0')) + || n == sizeof (uidbuf) + || (uidbuf[n] = '\0', + uid = strtoul (uidbuf, &endp, 10), + endp == uidbuf || *endp != '\0')) return 1; size_t buflen = 1024; @@ -84,8 +91,9 @@ __getlogin_r_loginuid (name, namesize) } -/* Return the login name of the user, or NULL if it can't be determined. - The returned pointer, if not NULL, is good only until the next call. */ +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occurred, return the error + code. Otherwise return 0. */ int getlogin_r (name, namesize) diff --git a/libc/sysdeps/unix/sysv/linux/i386/fallocate.c b/libc/sysdeps/unix/sysv/linux/i386/fallocate.c index 14e788386..1434a833f 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/fallocate.c +++ b/libc/sysdeps/unix/sysv/linux/i386/fallocate.c @@ -30,7 +30,13 @@ int fallocate (int fd, int mode, __off_t offset, __off_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; diff --git a/libc/sysdeps/unix/sysv/linux/i386/fallocate64.c b/libc/sysdeps/unix/sysv/linux/i386/fallocate64.c index 85f315c9b..063bab06e 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/fallocate64.c +++ b/libc/sysdeps/unix/sysv/linux/i386/fallocate64.c @@ -30,7 +30,13 @@ int fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; diff --git a/libc/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c b/libc/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c index 94760e0c2..0e309c3e2 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c +++ b/libc/sysdeps/unix/sysv/linux/s390/s390-32/makecontext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -28,15 +28,15 @@ double, complex and structure with sizes 0, 2, 4 or 8 won't work. makecontext sets up a stack and the registers for the - context. The stack looks like this: - size offset + user context. The stack looks like this: + size offset %r15 -> +-----------------------+ - 4 | back chain (zero) | 0 - 4 | reserved | 4 - 88 | save area for (*func) | 8 - +-----------------------+ - n | overflow parameters | 96 - +-----------------------+ + 4 | back chain (zero) | 0 + 4 | reserved | 4 + 88 | save area for (*func) | 8 + +-----------------------+ + n | overflow parameters | 96 + +-----------------------+ The registers are set up like this: %r2-%r6: parameters 1 to 5 %r7 : (*func) pointer @@ -54,27 +54,27 @@ void __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) { extern void __makecontext_ret (void); - unsigned long *sp; + unsigned long int *sp; va_list ap; - int i; - sp = (unsigned long *) (((unsigned long) ucp->uc_stack.ss_sp - + ucp->uc_stack.ss_size) & -8L); + sp = (unsigned long int *) (((unsigned long int) ucp->uc_stack.ss_sp + + ucp->uc_stack.ss_size) & -8L); /* Set the return address to trampoline. */ - ucp->uc_mcontext.gregs[14] = (long) __makecontext_ret; + ucp->uc_mcontext.gregs[14] = (long int) __makecontext_ret; /* Set register parameters. */ va_start (ap, argc); - for (i = 0; (i < argc) && (i < 5); i++) - ucp->uc_mcontext.gregs[2+i] = va_arg (ap, long); + for (int i = 0; i < argc && i < 5; ++i) + ucp->uc_mcontext.gregs[2 + i] = va_arg (ap, long int); /* The remaining arguments go to the overflow area. */ - if (argc > 5) { - sp -= argc - 5; - for (i = 5; i < argc; i++) - sp[i] = va_arg(ap, long); - } + if (argc > 5) + { + sp -= argc - 5; + for (int i = 5; i < argc; ++i) + sp[i - 5] = va_arg (ap, long int); + } va_end (ap); /* Make room for the save area and set the backchain. */ @@ -82,24 +82,24 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) *sp = 0; /* Pass (*func) to __start_context in %r7. */ - ucp->uc_mcontext.gregs[7] = (long) func; + ucp->uc_mcontext.gregs[7] = (long int) func; /* Pass ucp->uc_link to __start_context in %r8. */ - ucp->uc_mcontext.gregs[8] = (long) ucp->uc_link; + ucp->uc_mcontext.gregs[8] = (long int) ucp->uc_link; /* Pass address of setcontext in %r9. */ - ucp->uc_mcontext.gregs[9] = (long) &setcontext; + ucp->uc_mcontext.gregs[9] = (long int) &setcontext; /* Set stack pointer. */ - ucp->uc_mcontext.gregs[15] = (long) sp; + ucp->uc_mcontext.gregs[15] = (long int) sp; } -asm(".text\n" - ".type __makecontext_ret,@function\n" - "__makecontext_ret:\n" - " basr %r14,%r7\n" - " lr %r2,%r8\n" - " br %r9\n" - ".size __makecontext_ret, .-__makecontext_ret"); +asm (".text\n" + ".type __makecontext_ret,@function\n" + "__makecontext_ret:\n" + " basr %r14,%r7\n" + " lr %r2,%r8\n" + " br %r9\n" + ".size __makecontext_ret, .-__makecontext_ret"); weak_alias (__makecontext, makecontext) diff --git a/libc/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c b/libc/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c index b08f1b404..40ff3eefb 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c +++ b/libc/sysdeps/unix/sysv/linux/s390/s390-64/makecontext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -29,14 +29,14 @@ won't work. makecontext sets up a stack and the registers for the user context. The stack looks like this: - size offset + size offset %r15 -> +-----------------------+ - 8 | back chain (zero) | 0 - 8 | reserved | 8 - 144 | save area for (*func) | 16 - +-----------------------+ - n | overflow parameters | 160 - +-----------------------+ + 8 | back chain (zero) | 0 + 8 | reserved | 8 + 144 | save area for (*func) | 16 + +-----------------------+ + n | overflow parameters | 160 + +-----------------------+ The registers are set up like this: %r2-%r6: parameters 1 to 5 %r7 : (*func) pointer @@ -54,27 +54,27 @@ void __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) { extern void __makecontext_ret (void); - unsigned long *sp; + unsigned long int *sp; va_list ap; - int i; - sp = (unsigned long *) (((unsigned long) ucp->uc_stack.ss_sp - + ucp->uc_stack.ss_size) & -8L); + sp = (unsigned long int *) (((unsigned long int) ucp->uc_stack.ss_sp + + ucp->uc_stack.ss_size) & -8L); /* Set the return address to trampoline. */ - ucp->uc_mcontext.gregs[14] = (long) __makecontext_ret; + ucp->uc_mcontext.gregs[14] = (long int) __makecontext_ret; /* Set register parameters. */ va_start (ap, argc); - for (i = 0; (i < argc) && (i < 5); i++) - ucp->uc_mcontext.gregs[2+i] = va_arg (ap, long); + for (int i = 0; i < argc && i < 5; ++i) + ucp->uc_mcontext.gregs[2 + i] = va_arg (ap, long int); /* The remaining arguments go to the overflow area. */ - if (argc > 5) { - sp -= argc - 5; - for (i = 5; i < argc; i++) - sp[i] = va_arg(ap, long); - } + if (argc > 5) + { + sp -= argc - 5; + for (int i = 5; i < argc; ++i) + sp[i - 5] = va_arg (ap, long int); + } va_end (ap); /* Make room for the save area and set the backchain. */ @@ -82,24 +82,24 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) *sp = 0; /* Pass (*func) to __start_context in %r7. */ - ucp->uc_mcontext.gregs[7] = (long) func; + ucp->uc_mcontext.gregs[7] = (long int) func; /* Pass ucp->uc_link to __start_context in %r8. */ - ucp->uc_mcontext.gregs[8] = (long) ucp->uc_link; + ucp->uc_mcontext.gregs[8] = (long int) ucp->uc_link; /* Pass address of setcontext in %r9. */ - ucp->uc_mcontext.gregs[9] = (long) &setcontext; + ucp->uc_mcontext.gregs[9] = (long int) &setcontext; /* Set stack pointer. */ - ucp->uc_mcontext.gregs[15] = (long) sp; + ucp->uc_mcontext.gregs[15] = (long int) sp; } -asm(".text\n" - ".type __makecontext_ret,@function\n" - "__makecontext_ret:\n" - " basr %r14,%r7\n" - " lgr %r2,%r8\n" - " br %r9\n" - ".size __makecontext_ret, .-__makecontext_ret"); +asm (".text\n" + ".type __makecontext_ret,@function\n" + "__makecontext_ret:\n" + " basr %r14,%r7\n" + " lgr %r2,%r8\n" + " br %r9\n" + ".size __makecontext_ret, .-__makecontext_ret"); weak_alias (__makecontext, makecontext) |