[PATCH v2 3/4] tools/nolibc: sys.h: apply __sysret() helper
Zhangjin Wu
falcon at tinylab.org
Tue Jun 6 01:16:12 PDT 2023
Use __sysret() to shrink both brk() and getpagesize() to oneline code.
Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
tools/include/nolibc/sys.h | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index c12c14db056e..f6e3168b3e50 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -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);
}
--
2.25.1
More information about the linux-riscv
mailing list