Use __syscall_ret() helper to shrink the code lines of brk() and getpagesize(), 10 lines removed. Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx> --- tools/include/nolibc/sys.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 937a8578e3d4..976f23d1fdad 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -81,13 +81,9 @@ void *sys_brk(void *addr) static __attribute__((unused)) int brk(void *addr) { - void *ret = sys_brk(addr); + int ret = sys_brk(addr) ? 0 : -ENOMEM; - if (!ret) { - SET_ERRNO(ENOMEM); - return -1; - } - return 0; + return __syscall_ret(ret); } static __attribute__((unused)) @@ -550,15 +546,9 @@ static unsigned long getauxval(unsigned long key); static __attribute__((unused)) long getpagesize(void) { - long ret; + long ret = getauxval(AT_PAGESZ) ?: -ENOENT; - ret = getauxval(AT_PAGESZ); - if (!ret) { - SET_ERRNO(ENOENT); - return -1; - } - - return ret; + return __syscall_ret(ret); } -- 2.25.1