]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/nolibc: check for overflow in calloc() without divisions
authorThomas Weißschuh <linux@weissschuh.net>
Sat, 4 Apr 2026 11:50:19 +0000 (13:50 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Mon, 6 Apr 2026 17:46:52 +0000 (19:46 +0200)
commit1e3c374e9fd5ef0bf1ebcb866505b1aad404959e
treed6aa1b6831398bf62f34dd0d5d90ad419c6b0b5e
parent12496aad10c5671d66e160487326de942cd440ba
tools/nolibc: check for overflow in calloc() without divisions

On some architectures without native division instructions
the division can generate calls into libgcc/compiler-rt.
This library might not be available, so its use should be avoided.

Use the compiler builtin to check for overflows without needing a
division. The builtin has been available since GCC 3 and clang 3.8.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260404-nolibc-asprintf-v2-1-17d2d0df9763@weissschuh.net
tools/include/nolibc/stdlib.h