@@ -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);
}
Use __syscall_ret() helper to shrink the code lines of brk() and getpagesize(), 10 lines removed. Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/include/nolibc/sys.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)