@@ -78,13 +78,7 @@ void *sys_brk(void *addr)
static __attribute__((unused))
int brk(void *addr)
{
- void *ret = sys_brk(addr);
-
- if (!ret) {
- SET_ERRNO(ENOMEM);
- return -1;
- }
- return 0;
+ return __sysret(sys_brk(addr) ? 0 : -ENOMEM);
}
static __attribute__((unused))
@@ -547,15 +541,7 @@ static unsigned long getauxval(unsigned long key);
static __attribute__((unused))
long getpagesize(void)
{
- long ret;
-
- ret = getauxval(AT_PAGESZ);
- if (!ret) {
- SET_ERRNO(ENOENT);
- return -1;
- }
-
- return ret;
+ return __sysret(getauxval(AT_PAGESZ) ?: -ENOENT);
}
Use __sysret() to shrink both brk() and getpagesize() to oneline code. Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/include/nolibc/sys.h | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)