am 1fa69e47: Merge "Don\'t use errno directly"

* commit '1fa69e4787806be478ca8440468d598209da01e5':
  Don't use errno directly
This commit is contained in:
Andrew Hsieh
2013-03-20 07:51:19 -07:00
committed by Android Git Automerger
10 changed files with 35 additions and 31 deletions

View File

@@ -285,7 +285,7 @@ volatile int* WRAP(__errno)()
int save_errno;
/* pthread_* calls may modify errno so use a copy */
save_errno = errno;
save_errno = *REAL(__errno)();
p = errno_key_data();
@@ -322,7 +322,7 @@ volatile int* WRAP(__errno)()
ALOGV("%s: new save_errno:%d p:%p->{pshadow:%d, perrno:%d}", __func__,
save_errno, p, p->pshadow, p->perrno);
errno = save_errno;
*REAL(__errno)() = save_errno;
ALOGV("%s: return (&p->perrno):%p; }", __func__, &p->perrno);
@@ -338,7 +338,7 @@ void WRAP(__set_errno)(int portable_errno)
int save_errno;
/* pthread_* calls may modify errno so use a copy */
save_errno = errno;
save_errno = *REAL(__errno)();
p = errno_key_data();
@@ -352,7 +352,7 @@ void WRAP(__set_errno)(int portable_errno)
ALOGV("%s: new save_errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__,
save_errno, p, p->pshadow, p->perrno);
errno = save_errno;
*REAL(__errno)() = save_errno;
ALOGV("%s: return; }", __func__);
}

View File

@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <errno_portable.h>
#include <portability.h>
#include <fcntl_portable.h>
#include <filefd_portable.h>
@@ -317,7 +318,7 @@ int WRAP(fcntl)(int fd, int portable_cmd, ...)
if (invalid_pointer(flock_portable)) {
ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable);
errno = EFAULT;
*REAL(__errno)() = EFAULT;
result = -1;
goto done;
}
@@ -350,7 +351,7 @@ int WRAP(fcntl)(int fd, int portable_cmd, ...)
if (invalid_pointer(flock_portable)) {
ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable);
errno = EFAULT;
*REAL(__errno)() = EFAULT;
result = -1;
goto done;
}

View File

@@ -113,7 +113,7 @@ static int export_fd_env()
ALOGV("%s:() {", __func__);
saved_errno = errno;
saved_errno = *REAL(__errno)();
type_env_allocated = malloc(max_env_size);
fd_env_allocated = malloc(max_env_size);
@@ -216,7 +216,7 @@ done:
if (fd_env_allocated)
free(fd_env_allocated);
errno = saved_errno;
*REAL(__errno)() = saved_errno;
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;
@@ -239,7 +239,7 @@ static int import_fd_env(int verify)
ALOGV("%s:(verify:%d) {", __func__, verify);
saved_errno = errno;
saved_errno = *REAL(__errno)();
/*
* get file descriptor environment pointer and make a
@@ -328,7 +328,7 @@ done:
if (fd_env_allocated)
free(fd_env_allocated);
errno = saved_errno;
*REAL(__errno)() = saved_errno;
ALOGV("%s: return(rv:%d); }", __func__, rv);
return rv;

View File

@@ -39,13 +39,13 @@ static inline int mips_change_resource(int resource)
return resource;
}
extern int getrlimit(int resource, struct rlimit *rlp);
extern int REAL(getrlimit)(int resource, struct rlimit *rlp);
int WRAP(getrlimit)(int resource, struct rlimit *rlp)
{
return REAL(getrlimit)(mips_change_resource(resource), rlp);
}
extern int setrlimit(int resource, const struct rlimit *rlp);
extern int REAL(setrlimit)(int resource, const struct rlimit *rlp);
int WRAP(setrlimit)(int resource, const struct rlimit *rlp)
{
return REAL(setrlimit)(mips_change_resource(resource), rlp);

View File

@@ -1329,7 +1329,6 @@ __hidden int read_signalfd_mapper(int fd, void *buf, size_t count)
return rv;
}
int WRAP(sigsuspend)(const sigset_portable_t *portable_sigmask)
{
int rv;
@@ -1338,7 +1337,7 @@ int WRAP(sigsuspend)(const sigset_portable_t *portable_sigmask)
ALOGV("%s(portable_sigmask:%p) {", __func__, portable_sigmask);
if (invalid_pointer((void *)portable_sigmask)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
rv = -1;
} else {
sigset_pton((sigset_portable_t *)portable_sigmask, &mips_sigmask);
@@ -1359,7 +1358,7 @@ int WRAP(sigpending)(sigset_portable_t *portable_sigset)
portable_sigset);
if (invalid_pointer((void *)portable_sigset)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
rv = -1;
} else {
rv = REAL(sigpending)(&mips_sigset);
@@ -1382,7 +1381,7 @@ int WRAP(sigwait)(const sigset_portable_t *portable_sigset, int *ptr_to_portable
portable_sigset, ptr_to_portable_sig);
if (invalid_pointer((void *)portable_sigset)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
rv = -1;
} else {
sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset);
@@ -1508,7 +1507,7 @@ int WRAP(__rt_sigaction)(int portable_signum, const struct sigaction_portable *a
/* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
if (sigsetsize != (2* sizeof(long))) {
errno = EINVAL;
*REAL(__errno)() = EINVAL;
rv = -1;
goto done;
}
@@ -1533,7 +1532,7 @@ int WRAP(__rt_sigprocmask)(int portable_how,
/* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
if (sigsetsize != (2* sizeof(long))) {
errno = EINVAL;
*REAL(__errno)() = EINVAL;
rv = -1;
goto done;
}
@@ -1565,7 +1564,7 @@ int WRAP(__rt_sigtimedwait)(const sigset_portable_t *portable_sigset,
/* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
if (portable_sigsetsize != (2* sizeof(long))) {
errno = EINVAL;
*REAL(__errno)() = EINVAL;
rv = -1;
goto done;
}

View File

@@ -16,6 +16,7 @@
#include <portability.h>
#include <errno.h>
#include <errno_portable.h>
#include <stat_portable.h>
/* Note: The Portable Header will define stat to stat_portable */
@@ -25,7 +26,7 @@ int WRAP(stat)(const char *path, struct stat_portable *s)
int ret;
if (invalid_pointer(s)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(stat)(path, &mips_stat);
@@ -39,7 +40,7 @@ int WRAP(fstat)(int fd, struct stat_portable *s)
int ret;
if (invalid_pointer(s)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(fstat)(fd, &mips_stat);
@@ -53,7 +54,7 @@ int WRAP(lstat)(const char *path, struct stat_portable *s)
int ret;
if (invalid_pointer(s)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(lstat)(path, &mips_stat);
@@ -67,7 +68,7 @@ int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flag
int ret;
if (invalid_pointer(s)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(fstatat)(dirfd, path, &mips_stat, flags);

View File

@@ -17,6 +17,7 @@
#include <portability.h>
#include <string.h>
#include <errno.h>
#include <errno_portable.h>
#include <statfs_portable.h>
static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs)
@@ -40,7 +41,7 @@ int WRAP(statfs)(const char* path, struct statfs_portable* stat)
int ret;
if (invalid_pointer(stat)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(statfs)(path, &mips_stat);
@@ -54,7 +55,7 @@ int WRAP(fstatfs)(int fd, struct statfs_portable* stat)
int ret;
if (invalid_pointer(stat)) {
errno = EFAULT;
*REAL(__errno)() = EFAULT;
return -1;
}
ret = REAL(fstatfs)(fd, &mips_stat);

View File

@@ -597,7 +597,7 @@ int WRAP(syscall)(int portable_number, ...)
ALOGV("%s: native_number:%d <= 0; ret = -1; [ERROR: FIX SYSTEM CALL]", __func__,
native_number);
errno = ENOSYS;
*REAL(__errno)() = ENOSYS;
ret = -1;
goto done;
}
@@ -633,7 +633,7 @@ int WRAP(syscall)(int portable_number, ...)
done:
if (ret == -1) {
ALOGV("%s: ret == -1; errno:%d;", __func__, errno);
ALOGV("%s: ret == -1; errno:%d;", __func__, *REAL(__errno)());
}
ALOGV("%s: return(ret:%d); }", __func__, ret);
return ret;

View File

@@ -130,4 +130,6 @@
extern __hidden int errno_ntop(int native_errno);
extern __hidden int errno_pton(int native_errno);
extern volatile int* REAL(__errno)(void);
#endif /* _ERRNO_PORTABLE_H */

View File

@@ -75,9 +75,9 @@ static inline char *portable_tag() {
* to preserve the value of errno while logging.
*/
#define LOG_PRI(priority, tag, ...) ({ \
int _errno = errno; \
int _errno = *REAL(__errno)(); \
int _rv = android_printLog(priority, tag, __VA_ARGS__); \
errno = _errno; \
*REAL(__errno)() = _errno; \
_rv; /* Returned to caller */ \
})
@@ -85,14 +85,14 @@ static inline char *portable_tag() {
#include <cutils/log.h>
# define PERROR(str) { \
ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, errno, strerror(errno)); \
ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(errno)); \
}
# define ASSERT(cond) ALOG_ASSERT(cond, "assertion failed:(%s), file: %s, line: %d:%s", \
#cond, __FILE__, __LINE__, __func__);
#else
#include <assert.h>
# define PERROR(str) fprintf(stderr, "%s: PERROR('%s'): errno:%d:'%s'", __func__, str, errno, strerror(errno))
# define PERROR(str) fprintf(stderr, "%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(*REAL(__errno)()))
# define ASSERT(cond) assert(cond)
# define ALOGV(a,...)
# define ALOGW(a,...)