diff options
| author | H.J. Lu <hjl.tools@gmail.com> | 2015-10-13 12:00:45 -0700 |
|---|---|---|
| committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-13 12:01:10 -0700 |
| commit | 2caca60d065b659f7d42500a95e50c073d4a33a0 (patch) | |
| tree | 2fbb7091a6814776c845a48f62072133a6355647 | |
| parent | fb1cf108115f7e2e4510859693431b3473657d77 (diff) | |
| download | glibc-2caca60d065b659f7d42500a95e50c073d4a33a0.tar.xz glibc-2caca60d065b659f7d42500a95e50c073d4a33a0.zip | |
Use INLINE_SYSCALL_ERROR_RETURN_VALUE
This patch replaces
{
__set_errno (ERRNO);
return -1;
}
with INLINE_SYSCALL_ERROR_RETURN_VALUE (ERRNO).
* sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use
INLINE_SYSCALL_ERROR_RETURN_VALUE.
* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
* sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise.
* sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
* sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
* sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise.
* sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise.
* sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise.
* sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise.
* sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise.
* sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise.
* sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise.
* sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise.
* sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise.
* sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise.
* sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise.
* sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise.
* sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
* sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise.
* sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise.
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise.
* sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise.
* sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise.
* sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise.
* sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise.
(__xstat64_conv): Likewise.
(__xstat32_conv): Likewise.
30 files changed, 88 insertions, 158 deletions
@@ -1,5 +1,40 @@ 2015-10-13 H.J. Lu <hongjiu.lu@intel.com> + * sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use + INLINE_SYSCALL_ERROR_RETURN_VALUE. + * sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise. + * sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise. + * sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise. + * sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise. + * sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise. + * sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise. + * sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise. + * sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise. + * sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise. + * sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise. + * sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise. + * sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise. + * sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise. + * sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise. + * sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise. + * sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise. + * sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise. + * sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise. + * sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise. + * sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise. + * sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise. + * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise. + * sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise. + * sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise. + * sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise. + * sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise. + * sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise. + * sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise. + (__xstat64_conv): Likewise. + (__xstat32_conv): Likewise. + +2015-10-13 H.J. Lu <hongjiu.lu@intel.com> + * sysdeps/unix/sysv/linux/sysdep.h: New file. * sysdeps/unix/sysv/linux/i386/sysdep.c: Likewise. * sysdeps/unix/sysv/linux/alpha/sysdep.h: Include diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index b6fb7cf5db..4a496447e2 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -61,10 +61,7 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; tmp.tv_usec = itv->tv_usec % 1000000L; if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L; tntx.modes = ADJ_OFFSET_SINGLESHOT; } diff --git a/sysdeps/unix/sysv/linux/dl-openat64.c b/sysdeps/unix/sysv/linux/dl-openat64.c index 732097dd92..7d100bb321 100644 --- a/sysdeps/unix/sysv/linux/dl-openat64.c +++ b/sysdeps/unix/sysv/linux/dl-openat64.c @@ -33,7 +33,6 @@ openat64 (dfd, file, oflag) #ifdef __NR_openat return INLINE_SYSCALL (openat, 3, dfd, file, oflag | O_LARGEFILE); #else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS); #endif } diff --git a/sysdeps/unix/sysv/linux/eventfd.c b/sysdeps/unix/sysv/linux/eventfd.c index d4ffb3cedc..efce282617 100644 --- a/sysdeps/unix/sysv/linux/eventfd.c +++ b/sysdeps/unix/sysv/linux/eventfd.c @@ -38,16 +38,12 @@ eventfd (unsigned int count, int flags) kernel (sys_indirect) before implementing setting flags like O_NONBLOCK etc. */ if (flags != 0) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); # ifdef __NR_eventfd return INLINE_SYSCALL (eventfd, 1, count); # else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS); # endif #elif !defined __NR_eventfd2 # error "__ASSUME_EVENTFD2 defined but not __NR_eventfd2" diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index 1bb544fd4d..10ae62d6f9 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -35,10 +35,7 @@ faccessat (fd, file, mode, flag) int flag; { if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); if ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure))) return INLINE_SYSCALL (faccessat, 3, fd, file, mode); @@ -74,6 +71,5 @@ faccessat (fd, file, mode, flag) if (granted == mode) return 0; - __set_errno (EACCES); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EACCES); } diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index e278426de1..8df57cd3df 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -34,16 +34,10 @@ fchmodat (fd, file, mode, flag) int flag; { if (flag & ~AT_SYMLINK_NOFOLLOW) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); #ifndef __NR_lchmod /* Linux so far has no lchmod syscall. */ if (flag & AT_SYMLINK_NOFOLLOW) - { - __set_errno (ENOTSUP); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOTSUP); #endif return INLINE_SYSCALL (fchmodat, 3, fd, file, mode); diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index fa184db7fe..96e01e5748 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -36,8 +36,8 @@ do_fcntl (int fd, int cmd, void *arg) if (!INTERNAL_SYSCALL_ERROR_P (res, err)) return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - __set_errno (INTERNAL_SYSCALL_ERRNO (res, err)); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); } diff --git a/sysdeps/unix/sysv/linux/futimens.c b/sysdeps/unix/sysv/linux/futimens.c index 5f2b8a56cd..f39e1f28c5 100644 --- a/sysdeps/unix/sysv/linux/futimens.c +++ b/sysdeps/unix/sysv/linux/futimens.c @@ -33,15 +33,11 @@ futimens (int fd, const struct timespec tsp[2]) { #ifdef __NR_utimensat if (fd < 0) - { - __set_errno (EBADF); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EBADF); /* Avoid implicit array coercion in syscall macros. */ return INLINE_SYSCALL (utimensat, 4, fd, NULL, &tsp[0], 0); #else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS); #endif } #ifndef __NR_utimensat diff --git a/sysdeps/unix/sysv/linux/futimes.c b/sysdeps/unix/sysv/linux/futimes.c index 69ddfe1531..626802a39d 100644 --- a/sysdeps/unix/sysv/linux/futimes.c +++ b/sysdeps/unix/sysv/linux/futimes.c @@ -40,10 +40,7 @@ __futimes (int fd, const struct timeval tvp[2]) { if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000 || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]); TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]); diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c index 8d8c4e182a..26a9a5ab37 100644 --- a/sysdeps/unix/sysv/linux/fxstat.c +++ b/sysdeps/unix/sysv/linux/fxstat.c @@ -39,8 +39,7 @@ __fxstat (int vers, int fd, struct stat *buf) return INLINE_SYSCALL (fstat, 2, fd, (struct kernel_stat *) buf); #ifdef STAT_IS_KERNEL_STAT - errno = EINVAL; - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); #else struct kernel_stat kbuf; int result; diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c index c88bcecbd2..b94b1839e9 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c +++ b/sysdeps/unix/sysv/linux/fxstatat.c @@ -54,10 +54,8 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) #endif } else - { - __set_errno (INTERNAL_SYSCALL_ERRNO (result, err)); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result, + err)); } libc_hidden_def (__fxstatat) #ifdef XSTAT_IS_XSTAT64 diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index a55cf1d155..0af968a0bc 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -32,10 +32,7 @@ int __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) { if (__glibc_unlikely (vers != _STAT_VER_LINUX)) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); int result; INTERNAL_SYSCALL_DECL (err); @@ -44,9 +41,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1)) return 0; else - { - __set_errno (INTERNAL_SYSCALL_ERRNO (result, err)); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result, + err)); } libc_hidden_def (__fxstatat64) diff --git a/sysdeps/unix/sysv/linux/lutimes.c b/sysdeps/unix/sysv/linux/lutimes.c index 9e51305b9b..53dab12f0b 100644 --- a/sysdeps/unix/sysv/linux/lutimes.c +++ b/sysdeps/unix/sysv/linux/lutimes.c @@ -34,10 +34,7 @@ lutimes (const char *file, const struct timeval tvp[2]) { if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000 || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]); TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]); @@ -46,8 +43,7 @@ lutimes (const char *file, const struct timeval tvp[2]) return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW); #else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS); #endif } diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c index 948665c27a..fc4f7c6cea 100644 --- a/sysdeps/unix/sysv/linux/lxstat.c +++ b/sysdeps/unix/sysv/linux/lxstat.c @@ -38,8 +38,7 @@ __lxstat (int vers, const char *name, struct stat *buf) return INLINE_SYSCALL (lstat, 2, name, (struct kernel_stat *) buf); #ifdef STAT_IS_KERNEL_STAT - errno = EINVAL; - return -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); #else struct kernel_stat kbuf; int result; diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c index 0b160b6f6b..e4f83060b1 100644 --- a/sysdeps/unix/sysv/linux/mmap64.c +++ b/sysdeps/unix/sysv/linux/mmap64.c @@ -46,10 +46,7 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) } #endif if (offset & ((1 << page_shift) - 1)) - { - __set_errno (EINVAL); - return MAP_FAILED; - } + return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); void *result; result = (void *) INLINE_SYSCALL (mmap2, 6, addr, diff --git a/sysdeps/unix/sysv/linux/mq_open.c b/sysdeps/unix/sysv/linux/mq_open.c index 46c0cc871c..a3a623c4f3 100644 --- a/sysdeps/unix/sysv/linux/mq_open.c +++ b/sysdeps/unix/sysv/linux/mq_open.c @@ -35,10 +35,7 @@ mqd_t __mq_open (const char *name, int oflag, ...) { if (name[0] != '/') - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); mode_t mode = 0; struct mq_attr *attr = NULL; diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index a876c3c3ca..2af32a2787 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -26,10 +26,7 @@ int mq_unlink (const char *name) { if (name[0] != '/') - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); INTERNAL_SYSCALL_DECL (err); int ret = INTERNAL_SYSCALL (mq_unlink, err, 1, name + 1); @@ -41,8 +38,7 @@ mq_unlink (const char *name) ret = INTERNAL_SYSCALL_ERRNO (ret, err); if (ret == EPERM) ret = EACCES; - __set_errno (ret); - ret = -1; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (ret); } return ret; diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c index db88ba893c..b6e6e1c7e8 100644 --- a/sysdeps/unix/sysv/linux/prlimit.c +++ b/sysdeps/unix/sysv/linux/prlimit.c @@ -59,20 +59,14 @@ prlimit (__pid_t pid, enum __rlimit_resource resource, if (old_rlimit->rlim_cur != old_rlimit64_mem.rlim_cur) { if (new_rlimit == NULL) - { - __set_errno (EOVERFLOW); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); old_rlimit->rlim_cur = RLIM_INFINITY; } old_rlimit->rlim_max = old_rlimit64_mem.rlim_max; if (old_rlimit->rlim_max != old_rlimit64_mem.rlim_max) { if (new_rlimit == NULL) - { - __set_errno (EOVERFLOW); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); old_rlimit->rlim_max = RLIM_INFINITY; } } @@ -84,8 +78,7 @@ int prlimit (__pid_t pid, enum __rlimit_resource resource, const struct rlimit *new_rlimit, struct rlimit *old_rlimit) { - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN_V |
