summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorZhangjin Wu <falcon@tinylab.org>2023-07-07 17:59:53 +0300
committerWilly Tarreau <w@1wt.eu>2023-08-23 05:38:02 +0300
commit4201cfce15fe35d9d90ae870aba12eb84c0452ab (patch)
tree8d9c6002c59fe60e94d0d3f27c40745310144ab0 /tools/include
parent924e9539aeaa89e93268b4a39bac356e4355ab78 (diff)
downloadlinux-4201cfce15fe35d9d90ae870aba12eb84c0452ab.tar.xz
tools/nolibc: clean up sbrk() routine
Fix up the error reported by scripts/checkpatch.pl: ERROR: do not use assignment in if condition #95: FILE: tools/include/nolibc/sys.h:95: + if ((ret = sys_brk(0)) && (sys_brk(ret + inc) == ret + inc)) Apply the new generic __sysret() to merge the SET_ERRNO() and return lines. Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/sys.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 3d01a24e6f7a..61a3204b00d7 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -89,14 +89,13 @@ int brk(void *addr)
static __attribute__((unused))
void *sbrk(intptr_t inc)
{
- void *ret;
-
/* first call to find current end */
- if ((ret = sys_brk(0)) && (sys_brk(ret + inc) == ret + inc))
+ void *ret = sys_brk(0);
+
+ if (ret && sys_brk(ret + inc) == ret + inc)
return ret + inc;
- SET_ERRNO(ENOMEM);
- return (void *)-1;
+ return (void *)__sysret(-ENOMEM);
}