Although int = long effectively in i386, this makes it clear that a machine word-width value is being returned.
Also, future patches adding syscalls returning pointers can use the same type (long) for return value consistently.
While we're at it, slightly change SYSCALL_RET function macro to include the parameter only once.
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- loader/preloader.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/loader/preloader.c b/loader/preloader.c index 585be50624f..cb20afd4d5a 100644 --- a/loader/preloader.c +++ b/loader/preloader.c @@ -236,7 +236,7 @@ __ASM_GLOBAL_FUNC(_start,
/* wrappers for Linux system calls */
-#define SYSCALL_RET(ret) (((ret) < 0 && (ret) > -4096) ? -1 : (ret)) +#define SYSCALL_RET(ret) (((unsigned long)(ret) > -4096UL) ? -1 : (ret))
static inline __attribute__((noreturn)) void wld_exit( int code ) { @@ -247,7 +247,7 @@ static inline __attribute__((noreturn)) void wld_exit( int code )
static inline int wld_open( const char *name, int flags ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (5 /* SYS_open */), "r" (name), "c" (flags) ); return SYSCALL_RET(ret); @@ -255,7 +255,7 @@ static inline int wld_open( const char *name, int flags )
static inline int wld_close( int fd ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (6 /* SYS_close */), "r" (fd) ); return SYSCALL_RET(ret); @@ -263,7 +263,7 @@ static inline int wld_close( int fd )
static inline ssize_t wld_read( int fd, void *buffer, size_t len ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (3 /* SYS_read */), "r" (fd), "c" (buffer), "d" (len) @@ -273,7 +273,7 @@ static inline ssize_t wld_read( int fd, void *buffer, size_t len )
static inline ssize_t wld_write( int fd, const void *buffer, size_t len ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (4 /* SYS_write */), "r" (fd), "c" (buffer), "d" (len) ); return SYSCALL_RET(ret); @@ -281,7 +281,7 @@ static inline ssize_t wld_write( int fd, const void *buffer, size_t len )
static inline int wld_mprotect( const void *addr, size_t len, int prot ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (125 /* SYS_mprotect */), "r" (addr), "c" (len), "d" (prot) ); return SYSCALL_RET(ret); @@ -328,7 +328,7 @@ __ASM_GLOBAL_FUNC(wld_mmap,
static inline int wld_prctl( int code, long arg ) { - int ret; + long ret; __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx" : "=a" (ret) : "0" (172 /* SYS_prctl */), "r" (code), "c" (arg) ); return SYSCALL_RET(ret);