[PATCH] tools/nolibc: fix the function argument order of calloc()

Thomas Weißschuh posted 1 patch 4 hours ago
tools/include/nolibc/stdlib.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools/nolibc: fix the function argument order of calloc()
Posted by Thomas Weißschuh 4 hours ago
As per the man page, the number of elements should be the first argument
and the size of each one the second.

Switch the arguments around.

The behavior will not change, as both arguments are only multiplied with
each other.

Reported-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/lkml/aqQmCtPf_5M-BjRW@google.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/include/nolibc/stdlib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h
index 1816c2368b68..0e9748dcdb5f 100644
--- a/tools/include/nolibc/stdlib.h
+++ b/tools/include/nolibc/stdlib.h
@@ -143,7 +143,7 @@ void *malloc(size_t len)
 }
 
 static __attribute__((unused))
-void *calloc(size_t size, size_t nmemb)
+void *calloc(size_t nmemb, size_t size)
 {
 	size_t x;
 

---
base-commit: f2212892b6a0c2adab438783e9fa8093c90786d7
change-id: 20260924-nolibc-calloc-9fd3208470b4

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>